Download TCP/IP - WORLDFIP SUITE Software User Manual

Transcript
Socket functions
9. SEND()
9.1 Description
Once an application successfully establishes a socket connection, it is ready to transfer data over the connection.
An application sends data using the send function. Send is used on stream sockets or on connected datagram
sockets.
When sending data care must be taken not to exceed the maximum buffer sizes of the TCP or UDP layers:
•
•
stream socket: don't exceed the size defined by TCPSBS in TCPIP_Stack/Configuration/tcpipcfg.h
datagram socket: don't exceed the
TCPIP_Stack/Configuration/tcpipcfg.h
size
defined
by
(SIZE_OF_LRG_BUF
-
52)
in
In the case of a datagram socket if no buffer is available within the UDP layer then the function will return -1
and a call of the sockapi_get_last_error function will return ESOCKAPI_NOBUFS. This behaviour is
available for both a blocking and a non blocking socket.
In the case of a stream socket: if no buffer is available within the TCP layer then for a:
•
•
blocking socket: the function will block till the buffer contains enough space to copy the message and
transmit it,
non blocking socket: the function will return -1 and a call to the function sockapi_get_last_error
will return ESOCKAPI_NOBUFS.
Note
The successful completion of send does not indicate that the data was
successfully delivered.
Function syntax:
#include "sockapi.h"
int
send( int socket, char *buffer, int length, int flags );
9.2 Inputs
socket: a socket identifier created by the socket function
buffer: buffer containing the data to be transmitted
length: length of the data in the buffer
flags: not used
Page 8-18
TCP/IP - WORLDFIP SUITE
Software User Manual
ALS 53425 a-en