# Function Reference

# TCPSend

Sends data on a connected socket.

TCPSend ( mainsocket, data )

## Parameters

mainsocket | The connected socket identifier (SocketID) as returned by a TCPConnect() function.
data | binary/string to be send to the connected socket.

## Return Value

Success: | the number of bytes sent to the connected socket.
Failure: | 0 and sets the @error flag to non-zero.
@error: | Windows API WSAGetLastError return value (see MSDN).

## Remarks

If Unicode strings need to be transmitted they must be encoded/decoded with StringToBinary()/BinaryToString().
A test of TCPSend() and TCPRecv() can be launch with the following button :
Open TCPSend-Recv[2].au3

## Related

StringToBinary, TCPConnect, TCPListen, TCPRecv, TCPStartup, TCPTimeout (Option)