int ServerTCPWrite (unsigned int conversationHandle, void *dataPointer, unsigned int dataSize, unsigned int timeout);
Allows your program, acting as a TCP server, to send data to a client.
![]() |
Note  If the function call is successful the return value is the number of bytes written. It is possible that TCP is not able to write all the data in one call. If necessary, you can check the number of bytes written and call this function repeatedly to write the rest of the data as shown in the following example: |
char * buffer;
int messageSize;
int bytesToWrite;
int bytesWritten;
/* Initialize buffer and messageSize... */
bytesToWrite = messageSize;
while (bytesToWrite > 0)
{
bytesWritten = ServerTCPWrite (connectionHandle, &buffer[messageSize - bytesToWrite], bytesToWrite, 0);
bytesToWrite -= bytesWritten;
}
Input | ||
Name | Type | Description |
conversationHandle | unsigned integer | The conversation handle that uniquely represents the connection between the server and the client. |
dataPointer | void pointer | Pointer to the data to be written. NULL is not allowed. |
dataSize | unsigned integer | Number of bytes to write. |
timeout | unsigned integer | Number of milliseconds that ServerTCPWrite waits for data to be written to the connection. ServerTCPWrite returns as soon as it writes some data to the connection. The function waits the entire timeout period only if no data can be written. If you pass zero, the function uses a default timeout of 5,000 milliseconds. |
Name | Type | Description |
status | integer | Return value indicating whether the function was successful. Unless otherwise
stated, zero represents successful execution and a negative number represents
the error code. You can call the GetTCPSystemErrorString function to obtain a system message that describes the error. The system messages can be more descriptive than the TCP Library error codes. To obtain the correct system error message, you must call GetTCPSystemErrorString immediately after calling the TCP Library function that failed. For functions that read or write data (ClientTCPRead, ClientTCPWrite, ServerTCPRead, ServerTCPWrite), if the function was successful, the return value is the number of bytes transferred. You can have a maximum of 255 concurrent conversations and up to 1,024 connections. If you exceed this limit, |