TcpSend
Valid for: CANoe DE • CANoe4SW DEFunction Syntax
long TcpSend( dword socket, char buffer[], dword size); // from 1long TcpSend( dword socket, struct data[], dword size); // from 2long TcpSend( dword socket, byte buffer[], dword size); // from 3
Method Syntax
socket.Send( char buffer[], dword size); // form 1socket.Send( struct data[], dword size); // from 2socket.Send( byte buffer[], dword size); // from 3
Description
The function sends data on the specified socket. If the send operation does not complete immediately, the operation is performed asynchronously and the function will returnSOCKET_ERROR (-1).
Use IpGetLastSocketError to get a more specific error code. If the specific error code is WSA_IO_PENDING (997), this indicates an asynchronous sending.
The CAPL callback OnTcpSend will be called on completion (successful or not), providing that it is implemented in the same CAPL program.
Note: If the function returns with 0, the data were able to be sent immediately (synchronously). In this case, OnTcpSend is NOT called up. For this reason, you must relocate the code in OnTcpSend to a function or call up OnTcpSend explicitly.
Parameters
- socket: The socket handle.
- buffer: The buffer containing the data to be sent.
- data: The struct containing the data to be sent.
- size: The size of the data to be sent.
Return Values
- 0: The function completed successfully.
- WSA_INVALID_PARAMETER (87): The specified socket was invalid.
- SOCKET_ERROR (-1): The function failed. Call IpGetLastSocketError to get a more specific error code. If the specific error code is 997, this just indicates asynchronous sending. All other results are sending errors.