Home |
Function sendto |
Function sendtoSend data to a socket at the specified address. int sendto(SOCKET socket, const char * buffer, int buflen, int flags, const struct sockaddr * to, int tolen); ParameterssocketSocket returned by socket. bufferPointer to data to send. buflenNumber of bytes to send. flagsThe flags parameter provides options for calls to send. The following options are supported:
toDestination address; port number and IP address must be in network byte order. This parameter has type struct sockaddr * for historical reasons. Use type struct sockaddr_in * instead. tolenLength of valid information in *to structure. return valueThe number of bytes queued for sending, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Error Codes further describes each error. Possible values for this function are:
This routine sends n data bytes from buffer to the connection. For TCP, the socket must be connected and the parameters to and tolen are ignored. For UDP, the socket may be connected. Also, if the socket is not bound, the socket will be bound with a unique port number and the local IP address for the interface associated with the IP address sending the data to. For UDP and RAW (connected or unconnected), the IP address and port number (ignored for RAW) of the destination is in the parameter *to. If sendto is called with INADDR_BROADCAST, the packet is broadcast to all interfaces except loopback. In order to send to broadcast or multicast addresses, use sendto or connect with remote address set to the broadcast address (INADDR_BROADCAST) or to the multicast address respectfully. See send for more information.
|