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
-
25
- AF_APPLETALK → const int
-
16
- AF_ATM → const int
-
22
- AF_BAN → const int
-
21
- AF_BTH → const int
-
32
- AF_CCITT → const int
-
10
- AF_CHAOS → const int
-
5
- AF_CLUSTER → const int
-
24
- AF_DATAKIT → const int
-
9
- AF_DECnet → const int
-
12
- AF_DLI → const int
-
13
- AF_ECMA → const int
-
8
- AF_FIREFOX → const int
-
19
- AF_HYLINK → const int
-
15
- AF_HYPERV → const int
-
34
- AF_ICLFXBM → const int
-
31
- AF_IMPLINK → const int
-
3
- AF_INET → const int
-
2
- AF_INET6 → const int
-
23
- AF_IPX → const int
-
AF_NS
- AF_IRDA → const int
-
26
- AF_ISO → const int
-
7
- AF_LAT → const int
-
14
- AF_LINK → const int
-
33
- AF_NETBIOS → const int
-
17
- AF_NETDES → const int
-
28
- AF_NS → const int
-
6
- AF_OSI → const int
-
AF_ISO
- AF_PUP → const int
-
4
- AF_SNA → const int
-
11
- AF_TCNMESSAGE → const int
-
30
- AF_TCNPROCESS → const int
-
29
- AF_UNIX → const int
-
1
- AF_UNKNOWN1 → const int
-
20
- AF_UNSPEC → const int
-
0
- AF_VOICEVIEW → const int
-
18
- FD_ACCEPT → const int
-
0x08
- FD_CLOSE → const int
-
0x20
- FD_CONNECT → const int
-
0x10
- FD_OOB → const int
-
0x04
- FD_READ → const int
-
0x01
- FD_WRITE → const int
-
0x02
- 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.
0x0002
- SO_BROADCAST → const int
-
Configures a socket for sending broadcast data.
0x0020
- 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.
0x7000
- 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.
0x7004
- SO_CONNECT_TIME → const int
-
Returns the number of seconds a socket has been connected. This option is
only valid for connection-oriented protocols.
0x700C
- 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.
0x7001
- 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.
0x7005
- SO_DEBUG → const int
-
Enables debug output. Microsoft providers currently do not output any debug
information.
0x0001
- 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.
0x7002
- 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.
0x7006
- 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.
0x7003
- 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.
0x7007
- SO_DONTLINGER → const int
-
Does not block close waiting for unsent data to be sent.
~SO_LINGER
- 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).
0x0010
- SO_ERROR → const int
-
Returns the last error code on this socket. This per-socket error code is
not always immediately set.
0x1007
- SO_KEEPALIVE → const int
-
Enables sending keep-alive packets for a socket connection. Not supported on
ATM sockets (results in an error).
0x0008
- SO_LINGER → const int
-
Lingers on close if unsent data is present.
0x0080
- 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.
0x7009
- 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.
0x700A
- 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.
0x0100
- 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
0x7008
- SO_RCVBUF → const int
-
Specifies the total per-socket buffer space reserved for receives.
0x1002
- 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.
0x1004
- SO_RCVTIMEO → const int
-
Sets the timeout, in milliseconds, for blocking receive calls.
0x1006
- 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.
0x0004
- SO_SNDBUF → const int
-
Specifies the total per-socket buffer space reserved for sends.
0x1001
- 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.
0x1003
- SO_SNDTIMEO → const int
-
The timeout, in milliseconds, for blocking send calls.
0x1005
- SO_SYNCHRONOUS_ALERT → const int
-
0x10
- SO_SYNCHRONOUS_NONALERT → const int
-
0x20
- SO_TYPE → const int
-
Returns the socket type for the given socket (SOCK_STREAM or SOCK_DGRAM, for
example).
0x1008
- 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.
0x700B
- 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.
0x0040
- SOCK_DGRAM → const int
-
Datagram socket.
2
- SOCK_RAW → const int
-
Raw protocol interface.
3
- SOCK_RDM → const int
-
Reliably-delivered message.
4
- SOCK_SEQPACKET → const int
-
Sequenced packet stream.
5
- SOCK_STREAM → const int
-
Stream socket.
1
- TCP_BSDURGENT → const int
-
0x7000
- TCP_NODELAY → const int
-
0x0001
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.