[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.5 SDLNet_TCP_Send

int SDLNet_TCP_Send(TCPsocket sock, const void *data, int len)

This is a valid, connected, TCPsocket.
This is a pointer to the data to send over sock.
This is the length (in bytes) if the data.

Send data of length len over the socket sock.
This routine is not used for server sockets.

Returns: the number of bytes sent. If the number returned is less than len, then an error occured, such as the client disconnecting.

// send a hello over sock
//TCPsocket sock;
int len,result;
char *msg="Hello!";

len=strlen(msg)+1; // add one for the terminating NULL
if(result<len) {
    printf("SDLNet_TCP_Send: %s\n", SDLNet_GetError());
    // It may be good to disconnect sock because it is likely invalid now.

See Also:
3.3.6 SDLNet_TCP_Recv, 3.3.3 SDLNet_TCP_Accept, 3.3.1 SDLNet_TCP_Open, 3.3.4 SDLNet_TCP_GetPeerAddress, 3.3.2 SDLNet_TCP_Close, 4.2 TCPsocket

This document was generated on November, 3 2009 using texi2html