SDL Wiki
(This function is part of SDL_net, a separate library from SDL.)

SDLNet_TCP_Recv

Receive data from a non-server socket.

Header File

Defined in <SDL_net.h>

Syntax

int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen);

Function Parameters

TCPsocket sock the socket to send data to.
void * data a pointer to where to store received data.
int maxlen the maximum number of bytes that can be stored at data.

Return Value

(int) Returns number of bytes received, which might be less than maxlen.

Remarks

sock must be a valid socket that was created by SDLNet_TCP_Open with a specific address, or SDLNet_TCP_Accept.

Receive up to maxlen bytes of data over the non-server socket sock, and store them in the buffer pointed to by data.

This function returns the actual amount of data received. If the return value is less than or equal to zero, then either the remote connection was closed, or an unknown socket error occurred.

Note that this will return the number of bytes available at the first moment the socket is able to see new data. If packets are coming in slowly from the network, this might be less data than you expect at a given time.

This function may block! Use SDLNet_CheckSockets() to make sure there is data available before calling this function, if you want to avoid blocking.

Version

This function is available since SDL_net 2.0.0.

See Also


CategoryAPI, CategoryAPIFunction


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.