winsock2 library

Support for programming against the Win32 Windows Socket 2 library on Windows operating systems.

This library extends the core win32 library with Windows Socket functions. Since this library is somewhat specialist and many of its function names (e.g. send, connect) are likely to conflict with other libraries or programs, it is separately exported.

To add Winsock2 support to your app, use the additional line below:

import 'package:win32/win32.dart';
import 'package:win32/winsock2.dart' as winsock2;

Now you can call, for instance, winsock2.connect() or winsock2.send().

The winsock2 library will normally be used in conjunction with the main win32 library, and the latter will be required for constants and structs used here.

Classes

ADDRINFO struct
The addrinfoW structure is used by the GetAddrInfoW function to hold host address information.
FD_SET struct
The fd_set structure is used by various Windows Sockets functions and service providers, such as the select function, to place sockets into a set for various purposes, such as testing a given socket for readability using the readfds parameter of the select function.
HOSTENT struct
The hostent structure is used by functions to store information about a given host, such as host name, IPv4 address, and so forth. An application should never attempt to modify this structure or to free any of its components. Furthermore, only one copy of the hostent structure is allocated per thread, and an application should therefore copy any information that it needs before issuing any other Windows Sockets API calls.
IN_ADDR struct
The IN_ADDR structure represents an IPv4 Internet address.
PROTOENT struct
The protoent structure contains the name and protocol numbers that correspond to a given protocol name. Applications must never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread, and therefore, the application should copy any information it needs before issuing any other Windows Sockets function calls.
SERVENT struct
The servent structure is used to store or return the name and service number for a given service name.
SOCKADDR struct
The SOCKADDR structure stores socket address information.
TIMEVAL struct
The timeval structure is used to specify a time interval. It is associated with the Berkeley Software Distribution (BSD) Time.h header file.

Constants

AF_12844 → const int
AF_APPLETALK → const int
AF_ATM → const int
AF_BAN → const int
AF_BTH → const int
AF_CCITT → const int
AF_CHAOS → const int
AF_CLUSTER → const int
AF_DATAKIT → const int
AF_DECnet → const int
AF_DLI → const int
AF_ECMA → const int
AF_FIREFOX → const int
AF_HYPERV → const int
AF_ICLFXBM → const int
AF_INET → const int
AF_INET6 → const int
AF_IPX → const int
AF_IRDA → const int
AF_ISO → const int
AF_LAT → const int
AF_NETBIOS → const int
AF_NETDES → const int
AF_NS → const int
AF_OSI → const int
AF_PUP → const int
AF_SNA → const int
AF_TCNMESSAGE → const int
AF_TCNPROCESS → const int
AF_UNIX → const int
AF_UNKNOWN1 → const int
AF_UNSPEC → const int
AF_VOICEVIEW → const int
FD_ACCEPT → const int
FD_CLOSE → const int
FD_CONNECT → const int
FD_OOB → const int
FD_READ → const int
FD_WRITE → const int
SO_ACCEPTCONN → const int
Returns whether a socket is in listening mode. This option is only Valid for connection-oriented protocols. This socket option is not supported for the setting.
SO_BROADCAST → const int
Configures a socket for sending broadcast data.
SO_CONNDATA → const int
Additional data, not in the normal network data stream, that is sent with network requests to establish a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_CONNDATALEN → const int
The length, in bytes, of additional data, not in the normal network data stream, that is sent with network requests to establish a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_CONNECT_TIME → const int
Returns the number of seconds a socket has been connected. This option is only valid for connection-oriented protocols.
SO_CONNOPT → const int
Additional connect option data, not in the normal network data stream, that is sent with network requests to establish a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_CONNOPTLEN → const int
The length, in bytes, of connect option data, not in the normal network data stream, that is sent with network requests to establish a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_DEBUG → const int
Enables debug output. Microsoft providers currently do not output any debug information.
SO_DISCDATA → const int
Additional data, not in the normal network data stream, that is sent with network requests to disconnect a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_DISCDATALEN → const int
The length, in bytes, of additional data, not in the normal network data stream, that is sent with network requests to disconnect a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_DISCOPT → const int
Additional disconnect option data, not in the normal network data stream, that is sent with network requests to disconnect a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_DISCOPTLEN → const int
The length, in bytes, of additional disconnect option data, not in the normal network data stream, that is sent with network requests to disconnect a connection. This option is used by legacy protocols such as DECNet, OSI TP4, and others. This option is not supported by the TCP/IP protocol in Windows.
SO_DONTLINGER → const int
Does not block close waiting for unsent data to be sent.
SO_DONTROUTE → const int
Sets whether outgoing data should be sent on interface the socket is bound to and not a routed on some other interface. This option is not supported on ATM sockets (results in an error).
SO_ERROR → const int
Returns the last error code on this socket. This per-socket error code is not always immediately set.
SO_KEEPALIVE → const int
Enables sending keep-alive packets for a socket connection. Not supported on ATM sockets (results in an error).
SO_LINGER → const int
Lingers on close if unsent data is present.
SO_MAXDG → const int
Returns the maximum size, in bytes, for outbound datagrams supported by the protocol. This socket option has no meaning for stream-oriented sockets.
SO_MAXPATHDG → const int
Returns the maximum size, in bytes, for outbound datagrams supported by the protocol to a given destination address. This socket option has no meaning for stream-oriented sockets. Microsoft providers may silently treat this as SO_MAXDG.
SO_OOBINLINE → const int
Indicates that out-of-bound data should be returned in-line with regular data. This option is only valid for connection-oriented protocols that support out-of-band data.
SO_OPENTYPE → const int
Once set, affects whether subsequent sockets that are created will be non-overlapped. The possible values for this option are SO_SYNCHRONOUS_ALERT and SO_SYNCHRONOUS_NONALERT. This option should not be used. Instead use the WSASocket function and leave the WSA_FLAG_OVERLAPPED bit in the dwFlags parameter turned off
SO_RCVBUF → const int
Specifies the total per-socket buffer space reserved for receives.
SO_RCVLOWAT → const int
A socket option from BSD UNIX included for backward compatibility. This option sets the minimum number of bytes to process for socket input operations.
SO_RCVTIMEO → const int
Sets the timeout, in milliseconds, for blocking receive calls.
SO_REUSEADDR → const int
Allows the socket to be bound to an address that is already in use. For more information, see bind. Not applicable on ATM sockets.
SO_SNDBUF → const int
Specifies the total per-socket buffer space reserved for sends.
SO_SNDLOWAT → const int
A socket option from BSD UNIX included for backward compatibility. This option sets the minimum number of bytes to process for socket output operations.
SO_SNDTIMEO → const int
The timeout, in milliseconds, for blocking send calls.
SO_SYNCHRONOUS_ALERT → const int
SO_SYNCHRONOUS_NONALERT → const int
SO_TYPE → const int
Returns the socket type for the given socket (SOCK_STREAM or SOCK_DGRAM, for example).
SO_UPDATE_ACCEPT_CONTEXT → const int
This option is used with the AcceptEx function. This option updates the properties of the socket which are inherited from the listening socket. This option should be set if the getpeername, getsockname, getsockopt, or setsockopt functions are to be used on the accepted socket.
SO_USELOOPBACK → const int
Use the local loopback address when sending data from this socket. This option should only be used when all data sent will also be received locally. This option is not supported by the Windows TCP/IP provider.
SOCK_DGRAM → const int
Datagram socket.
SOCK_RAW → const int
Raw protocol interface.
SOCK_RDM → const int
Reliably-delivered message.
SOCK_SEQPACKET → const int
Sequenced packet stream.
SOCK_STREAM → const int
Stream socket.
TCP_BSDURGENT → const int
TCP_NODELAY → const int

Functions

accept(int s, Pointer<SOCKADDR> addr, Pointer<Int32> addrlen) int winsock
The accept function permits an incoming connection attempt on a socket.
bind(int s, Pointer<SOCKADDR> name, int namelen) int winsock
The bind function associates a local address with a socket.
closesocket(int s) int winsock
The closesocket function closes an existing socket.
connect(int s, Pointer<SOCKADDR> name, int namelen) int winsock
The connect function establishes a connection to a specified socket.
GetAddrInfo(Pointer<Utf16> pNodeName, Pointer<Utf16> pServiceName, Pointer<ADDRINFO> pHints, Pointer<Pointer<ADDRINFO>> ppResult) int winsock
The GetAddrInfoW function provides protocol-independent translation from a Unicode host name to an address.
gethostbyaddr(Pointer<Utf8> addr, int len, int type) Pointer<HOSTENT> winsock
The gethostbyaddr function retrieves the host information corresponding to a network address.
gethostbyname(Pointer<Utf8> name) Pointer<HOSTENT> winsock
The gethostbyname function retrieves host information corresponding to a host name from a host database.
gethostname(Pointer<Utf8> name, int namelen) int winsock
The gethostname function retrieves the standard host name for the local computer.
getnameinfo(Pointer<SOCKADDR> pSockaddr, int SockaddrLength, Pointer<Utf8> pNodeBuffer, int NodeBufferSize, Pointer<Utf8> pServiceBuffer, int ServiceBufferSize, int Flags) int winsock
The getnameinfo function provides protocol-independent name resolution from an address to an ANSI host name and from a port number to the ANSI service name.
getpeername(int s, Pointer<SOCKADDR> name, Pointer<Int32> namelen) int winsock
The getpeername function retrieves the address of the peer to which a socket is connected.
getprotobyname(Pointer<Utf8> name) Pointer<PROTOENT> winsock
The getprotobyname function retrieves the protocol information corresponding to a protocol name.
getprotobynumber(int number) Pointer<PROTOENT> winsock
The getprotobynumber function retrieves protocol information corresponding to a protocol number.
getservbyname(Pointer<Utf8> name, Pointer<Utf8> proto) Pointer<SERVENT> winsock
The getservbyname function retrieves service information corresponding to a service name and protocol.
getservbyport(int port, Pointer<Utf8> proto) Pointer<SERVENT> winsock
The getservbyport function retrieves service information corresponding to a port and protocol.
getsockname(int s, Pointer<SOCKADDR> name, Pointer<Int32> namelen) int winsock
The getsockname function retrieves the local name for a socket.
getsockopt(int s, int level, int optname, Pointer<Utf8> optval, Pointer<Int32> optlen) int winsock
The getsockopt function retrieves a socket option.
htonl(int hostlong) int winsock
The htonl function converts a u_long from host to TCP/IP network byte order (which is big-endian).
htons(int hostshort) int winsock
The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).
inet_addr(Pointer<Utf8> cp) int winsock
The inet_addr function converts a string containing an IPv4 dotted-decimal address into a proper address for the IN_ADDR structure.
inet_ntoa(IN_ADDR in_) Pointer<Utf8> winsock
The inet_ntoa function converts an (Ipv4) Internet network address into an ASCII string in Internet standard dotted-decimal format.
inet_ntop(int Family, Pointer<NativeType> pAddr, Pointer<Utf8> pStringBuf, int StringBufSize) Pointer<Utf8> winsock
The inet_ntop function converts an IPv4 or IPv6 Internet network address into a string in Internet standard format.
ioctlsocket(int s, int cmd, Pointer<Uint32> argp) int winsock
The ioctlsocket function controls the I/O mode of a socket.
listen(int s, int backlog) int winsock
The listen function places a socket in a state in which it is listening for an incoming connection.
ntohl(int netlong) int winsock
The ntohl function converts a u_long from TCP/IP network order to host byte order (which is little-endian on Intel processors).
ntohs(int netshort) int winsock
The ntohs function converts a u_short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).
recv(int s, Pointer<Utf8> buf, int len, int flags) int winsock
The recv function receives data from a connected socket or a bound connectionless socket.
recvfrom(int s, Pointer<Utf8> buf, int len, int flags, Pointer<SOCKADDR> from, Pointer<Int32> fromlen) int winsock
The recvfrom function receives a datagram, and stores the source address.
select(int nfds, Pointer<FD_SET> readfds, Pointer<FD_SET> writefds, Pointer<FD_SET> exceptfds, Pointer<TIMEVAL> timeout) int winsock
The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
send(int s, Pointer<Utf8> buf, int len, int flags) int winsock
The send function sends data on a connected socket.
sendto(int s, Pointer<Utf8> buf, int len, int flags, Pointer<SOCKADDR> to, int tolen) int winsock
The sendto function sends data to a specific destination.
shutdown(int s, int how) int winsock
The shutdown function disables sends or receives on a socket.
socket(int af, int type, int protocol) int winsock
The socket function creates a socket that is bound to a specific transport service provider.