GEOS SDK TechDocs|
|
7.1 Urgent Data |
7.3 Options
The
SocketSend()
routine sends data over a socket. It takes several arguments:
SocketConnect()
routine to specify a default destination address. If they have no default address, you must specify the destination address for the packet. If there is a default destination address and you pass this optional address, then the optional address overrides the default for this send.Note that in some domains, the driver may delay before sending small packets of data because it is waiting for more packets to combine into one large packet. In many cases, this leads to more efficient communication. You may turn off this behavior by setting the "no delay" option. See SO_NODELAY: No Delay for small packets To force a driver to send small packets without waiting for other packets to bundle together. Drivers often delay sending small packets, waiting for other packets to bundle together in one larger packet. Th for information about setting socket options.
The
SocketRecv()
routine receives data from the socket. After filling the passed buffer with data, the socket discards its copy of the received data to make room for the next piece of incoming data.
Sequenced packet or datagram delivery sockets can only receive whole packets. If you grab data from the socket but don't grab all the data in the packet, the remaining data is lost. Thus, it's a good idea to establish a maximum packet size for sockets using these delivery types. If you're not sure how much room you'll need to receive a packet, call
SocketRecv()
with the SRF_PEEK flag. This allows you to "peek" at the incoming data without causing the socket to discard its copy.
The
SocketRecv()
routine takes the following arguments:
SocketAddress
buffer. (The buffer's
SA_domain
,
SA_domainSize
, and
SA_addressSize
fields must be initialized.) Make sure the buffer has room for the address data after the
SocketAddress
structure. Note that if either the domain name buffer or the address buffer isn't long enough to hold its string, the resulting truncated string isn't null-terminated.
The
SocketRecv()
routine returns the size of the received buffer. If this size is zero, there may be an error in the connection. Use
ThreadGetError()
to check for an error. If
ThreadGetError()
returns SE_NORMAL, then there was no error and you received a zero-length packet. For a datagram connection, an SE_EXCEPTION error indicates that the network is having problems and some datagrams
may
not be getting through.
GEOS SDK TechDocs|
|
7.1 Urgent Data |
7.3 Options