2011年8月27日星期六

sendto ()

...

a specified destination point to send data,godbo.com, sendto () for interlocked datagram alternatively stream socket to send data.

directory

Introduction Notes: It was reported that type socket to send broadcast data value significance Returns: Error code: Introduction # contain integer PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, integer flags, const struct sockaddr FAR * apt, int tolen); s: a socket descriptor identifies. buf: buffer containing file to be brought. len: buf data buffer width. flags: invocation flags. to: (optional) pointer apt point to the socket residence. tolen: to the address referred to the length.

Note: It is reported for the datagram socket class Socket class, must pay care to communications to send data length ought not exceed the highest length of the subnet of the IP parcel. IP pouch length in WSAStartup () phone returns WSAData of iMaxUdpDg ingredient. If the data namely also long automatically at the underlying protocol, WSAEMSGSIZE mistake is returned, the data will no be sent. Please memorandum namely successful achievement sendto () call does not mean namely data convey arrives. sendto () function is primarily accustom for SOCK_DGRAM socket type parameter to clarify the side to send a datagram socket. For SOCK_STREAM type sockets, to and tolen parameters are ignored; this case, sendto () is equivalent to send (). Send announce data to transmit announce data (for SOCK_DGRAM), in the characteristic parameters contained in the address should be the IP address of INADDR_BROADCAST (winsock.h have defined) and the extremity address of integrated structure. Generally suggested that a broadcast datagram size is not massive so shredded,bstsg.net, that is portion of the data parcel (including header) does not exceed 512 bytes. If the transmission system is not enough buffer space to retention data to be transmitted, unless the socket is in non-blocking I / O mode, or sendto () will stop. For non-blocking SOCK_STREAM socket type, the substantial number of jot data to the desired size may be between 1 and its worth depends above the regional and remote host buffer size. Can choose () call to make sure when to send the data further. In the relevant socket options above, tin likewise affect the feature flag to flag the implementation. In other words, the semantics of this feature depends on either the socket discretion also depends on the flag. The latter consists of the emulating values: Value Meaning MSG_DONTROUTE specified data is not selected trail. A socket suppliers WINDOWS can bypass this flag; see Section 2.4 on SO_DONTROUTE dispute. MSG_OOB orchestra data was sent (only SO_STREAM; watch section 2.2.3). Return value: If not error occurs, send () returns the total digit of sent data (Please note that this diagram may be fewer than the size specified in len). Otherwise, it returns SOCKET_ERROR error, the application at WSAGetLastError () to win the corresponding error code. Error code: WSANOTINITIALISED: Before using this API [should 1st successful call to WSAStartup (). WSAENETDOWN: WINDOWS set of interface test] to the web subsystem has failed. WSAEACESS: requested address is a broadcast address, but the relevant flag not correctly set. WSAEINTR: through a WSACancelBlockingCall () to cancel a (blocking) call. WSAEINPROGRESS: a socket call blocking WINDOWS is sprinting. WSAEFAULT: buf or to parameters are not user address space [portion, or to parameters are too small (less than the size of the sockaddr structure). WSAENETRESET: set interface put due WINDOWS] forsook articulation, so the linkage have to be reset. WSAENOBUFS: WINDOWS Sockets implementation reports a buffer deadlock. WSAENOTCONN: socket is not connected. WSAENOTSOCK: The descriptor is not a socket. WSAEOPNOTSUPP: set up MSG_OOB, but non-socket of type SOCK_STREAM. WSAESHUTDOWN: socket has been closed. A socket 1 or 2, how to dialectic call shutdown () is closed, you can not then sned () function. WSAEWOULDBLOCK: socket is marked as non-blocking, but will have the call block. WSAEMSGSIZE: as SOCK_DGRAM socket type, and the datagram is greater than the WINDOWS interface sets the maximum aided. WSAECONNABORTED: due to timeout or other occasions virtual circle interruption. WSAECONNRESET: virtual circle was reset remotely. WSAEADDRNOTAVAIL: referring to the address can not be obtained from the regional host. WSAEAFNOSUPPORT: the specified address family can not address all of the socket to use. WSAEDESADDRREQ: destination address required. WSAENETUNREACH: not currently correlated from the host on the network. See: recv (), recvfrom (), socket (), send (), WSAStartup (). Further reading: 1

following are WSAGetLastError () function may return error codes and corresponding explanations. Error code values ​​for all Windows Sockets-compatible implementation are consistent.

2

Windows Sockets Berkeley error values ​​to annotate

3

code corresponding to the code

4

WSAEINTR EINTR 10004 consistent with the standard C

5

WSAEBADF EBADF 10009 consistent with the standard C

6

WSAEACCES EACCES 10013 consistent with the criterion C

7

WSAEFAULT EFAULT 10014 consistent with the standard C

8

WSAEINVAL EINVAL 10022 consistent with the standard C

9

WSAEMFILE EMFILE 10024 consistent with the standard C

10

WSAEWOULD EWOULD 10035 consistent with the BSD

11

WSAEINPRO EINPRO 10036 When the application Call

12

GRESS GRESS Windows Sockets API function, if a blocking function is run, will return the error.

13

WSAEALREADY EALREADY 10037 consistent with the BSD

14

WSAENOTSOCK ENOTSOCK 10038 consistent with the BSD

15

WSAEDESTADDR EDESTADDR 10039 consistent with the BSD

16

WSAEMSGSIZE EMSGSIZE 10040 invariable with the BSD

17

WSAEPROTOTYPE EPROTOTYPE 10041 consistent with the BSD

18

WSAENOPROTO ENOPROTOOPT 10042 consistent with the BSD

19

WSAEPROTONO EPROTONO consistent with the BSD 10043

20

WSAESOCKTNO ESOCKTNO 10044 consistent with the BSD

Open Category: Programming

没有评论:

发表评论