Receiving Messages - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Using Internet Datagram Sockets
Sending and Receiving Messages
Parameter
Description of Contents
flags
settings for optional flags
to
address of recipient socket
tolen
size of to
Function result: Number of bytes actually sent, –1 in the event of an
error.
Example:
count = sendto(s,argv[2],strlen(argv[2]),0,servaddr,sizeof(struct
sockaddr_in));
The largest message size for this implementation is 32767 bytes.
You should not count on receiving error messages when using datagram
sockets. The protocol is unreliable, meaning that messages may or may
not reach their destination. However, if a message reaches its
destination, the contents of the message are guaranteed to be intact.
If you need reliable message transfer, you must build it into your
application programs or resend a message if the expected response does
not occur.
When to Send Data
The client or server process should send data after sockets are bound.
Refer to the send(2) man page for more information on sendto and
sendmsg.

Receiving Messages

Use recvfrom or recvmsg to receive messages. recvmsg allows the
read data to be scattered into buffers.
96
INPUT Value
0 (no options are
currently supported)
pointer to the socket
address that message
should be sent to
length of address
structure that to points
to
Chapter 4

Advertisement

Table of Contents
loading

Table of Contents