sdlNetTcpRecv function
Receive data from a non-server socket.
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.
\param sock the socket to send data to.
\param data a pointer to where to store received data.
\param maxlen the maximum number of bytes that can be stored at data
.
\returns number of bytes received, which might be less than maxlen
.
\since This function is available since SDL_net 2.0.0.
\sa SDLNet_TCP_Send \sa SDLNet_CheckSockets
extern DECLSPEC int SDLCALL SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
Implementation
int sdlNetTcpRecv(
Pointer<TCPsocket> sock, Pointer<NativeType> data, int maxlen) {
final sdlNetTcpRecvLookupFunction = libSdl2Net.lookupFunction<
Int32 Function(
Pointer<TCPsocket> sock, Pointer<NativeType> data, Int32 maxlen),
int Function(Pointer<TCPsocket> sock, Pointer<NativeType> data,
int maxlen)>('SDLNet_TCP_Recv');
return sdlNetTcpRecvLookupFunction(sock, data, maxlen);
}