Tao.Sdl SDK Documentation

SdlNet.SDLNet_TCP_Send Method 

Send data over a connected socket

[Visual Basic]
Public Shared Function SDLNet_TCP_Send( _
   ByVal sock As TCPsocket, _
   ByVal data As IntPtr, _
   ByVal len As Integer _
) As Integer
[C#]
public static int SDLNet_TCP_Send(
   TCPsocket sock,
   IntPtr data,
   int len
);

Parameters

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

Return Value

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

Remarks

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

Binds to C-function call in SDL_net.h:

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

Example

            // send a hello over sock
            //TCPsocket sock;
            int len,result;
            char *msg="Hello!";
            len=strlen(msg)+1; // add one for the terminating NULL
            result=SDLNet_TCP_Send(sock,msg,len);
            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

SdlNet Class | Tao.Sdl Namespace | SDLNet_TCP_Open | SDLNet_TCP_Close | SDLNet_TCP_Accept | SDLNet_TCP_Recv | SDLNet_TCP_GetPeerAddress | SdlNet.TCPsocket