HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 156
can also be used if you do not need to know what socket sent
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 156 highlights
Using UNIX Domain Datagram Sockets Sending and Receiving Messages Function result: number of bytes actually sent if sendto succeeds, -1 if sendto call fails. Example: struct sockaddr_un servaddr; ... count = sendto(s, argv[2], strlen(argv[2]), 0, &servaddr, sizeof(struct sockaddr_un); When to Send Data The server or client process should send data after server has bound to an address. Refer to the send(2) man page for more information on sendto and sendmsg. Receiving Messages Use recvfrom or recvmsg to receive messages. recvmsg is similar to recvfrom, except recvmsg allows the read data to be scattered into buffers. recv can also be used if you do not need to know what socket sent the message. However, if you want to send a response to the message, you must know where it came from. Except for the extra information returned by recvfrom, the two calls are identical. recvfrom and its parameters are described in the following table. Include files: System call: #include #include #include count = recvfrom(s, msg, len, flags, from, fromlen) int s; char *msg; int len, flags; struct sockaddr_un *from; int *fromlen; 156 Chapter 7