sdlNetTcpSend function

int sdlNetTcpSend(
  1. Pointer<TCPsocket> sock,
  2. Pointer<NativeType> data,
  3. int len
)

Send data over 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.

This function sends len bytes, pointed to by data over the non-server socket sock.

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

This function may block!

\param sock the socket to send data to. \param data a pointer to the bytes to send. \param len the number of bytes, pointed to by data, to transmit. \returns number of bytes sent, which might be less if there was a problem or connection failure. If the socket is invalid, this function can return -1, but in valid uses it'll return >= 0.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_TCP_Recv

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

Implementation

int sdlNetTcpSend(Pointer<TCPsocket> sock, Pointer<NativeType> data, int len) {
  final sdlNetTcpSendLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(
          Pointer<TCPsocket> sock, Pointer<NativeType> data, Int32 len),
      int Function(Pointer<TCPsocket> sock, Pointer<NativeType> data,
          int len)>('SDLNet_TCP_Send');
  return sdlNetTcpSendLookupFunction(sock, data, len);
}