I am learning UNIX domain sockets and trying out some client server programs. I am using SOCK_DGRAM family of sockets.
My doubt is:
So my call:
sendto(send_thread_socket, (void*)argData, sizeof(*argData), 0,
(struct sockaddr *)&dpdkServer, sizeof(struct sockaddr_un))
will it copy the buffer to some kernel space buffer or will it directly be copied to user space buffer of receiving process. Since UNIX sockets work on file system namespaces I thought it shouldn't do a copy of the buffer.
Lets say I am using the same sendto() call, but the receiving side does not guarantee any timely collection of data, can I have a Send timeout.
The function sendto does not wait for the data to be received by the recipient before it returns. So yes, to achieve that, the data will be copied to a buffer owned by the kernel and then copied out again by the recieving process.
Why: If this wasn't the case, then it would be more-or-less impossible for two processes to exchange messages. If process P1 attempts to send a message to process P2, it would not succeed until P2 called read. If P2 is attempting to send a messate to P1 at the time, it cannot succeed until P1 calls read. But P1 is waiting in a blocking call to sendto. The processes will be deadlocked.
Buffering by the kernel is the solution to that problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With