Sendmsg file descriptor example




















The msgvec argument is a pointer to an array of mmsghdr structures. The size of this array is specified in vlen. The flags argument contains flags ORed together. The flags are the same as for sendmsg 2. A blocking sendmmsg call blocks until vlen messages have been sent. A nonblocking call sends as many messages as possible up to the limit specified by vlen and returns immediately. The return value of the call indicates the number of elements of msgvec that have been updated. Return Value On success, sendmmsg returns the number of messages sent from msgvec ; if this is less than vlen , the caller can retry with a further sendmmsg call to send the remaining messages.

On error, -1 is returned, and errno is set to indicate the error. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to use sendmsg to send a file-descriptor via sockets between 2 processes? Ask Question. Asked 10 years, 1 month ago. Active 8 years, 10 months ago. Viewed 19k times. Improve this question. Community Bot 1 1 1 silver badge. Fouad Eng. Fouad k 65 65 gold badges silver badges bronze badges.

Add a comment. Active Oldest Votes. The following would work I omitted some of the error handling. Improve this answer. After sendmsg, what's the state of the fd in the server? In example code I never see server closing the fd, which would be necessary if sendmsg doesn't close it. I believe it stays open and the OS closes it when the process terminates if you don't first.

Haven't fully checked that though. David Schwartz David Schwartz k 17 17 gold badges silver badges bronze badges. Use a UNIX domain socket. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.



0コメント

  • 1000 / 1000