Hi to everyone, I'd like to do a scattered write, like with writev() on a Unix Domain Socket. The problem is, since the socket is of SOCK_DGRAM type, and thus unconnected, writev will fail saying "Transport endpoint is not connected". I checked in the man pages and yes, write() and writev() will not work on datagram-type sockets. The question is: is there a way to perform a scattered write on a datagram Unix Socket? I don't know why it shouldn't be, but I wouldn't be surprised if Linux API were lacking also of this possibility. I use kernel 2.6.10. Thanks, Regards, Cristiano.
janesconference@gmail.com writes: > Hi to everyone, I'd like to do a scattered write, like with writev() > on a Unix Domain Socket. The problem is, since the socket is of > SOCK_DGRAM type, and thus unconnected, writev will fail saying > "Transport endpoint is not connected". > I checked in the man pages and yes, write() and writev() will not work > on datagram-type sockets. > > The question is: is there a way to perform a scattered write on a > datagram Unix Socket? Two ways, actually: It is possible to use connect with a datagram socket, too, which then sets the default destination address for send-operations not specifying one and the acceptable recipient address for recv. Afterwards, send, write or writev could be used as with any other connected socket. The second one would be to use sendmsg instead of sendto.
janesconference@gmail.com writes: > Hi to everyone, I'd like to do a scattered write, like with writev() > on a Unix Domain Socket. The problem is, since the socket is of > SOCK_DGRAM type, and thus unconnected, writev will fail saying > "Transport endpoint is not connected". > I checked in the man pages and yes, write() and writev() will not work > on datagram-type sockets. Does your system have sendmsg()? It should. The msghdr structure contains a msg_iov member that points to an array of scatter buffers, as well as a msg_name pointer for the destination address. -- James Carlson, Solaris Networking <james.d.carlson@sun.com> Sun Microsystems / 35 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
On 6 Mag, 14:25, James Carlson <james.d.carl...@sun.com> wrote: > janesconfere...@gmail.com writes: > > Hi to everyone, I'd like to do a scattered write, like with writev() > > on a Unix Domain Socket. The problem is, since the socket is of > > SOCK_DGRAM type, and thus unconnected, writev will fail saying > > "Transport endpoint is not connected". > > I checked in the man pages and yes, write() and writev() will not work > > on datagram-type sockets. > > Does your system have sendmsg()? =A0It should. =A0The msghdr structure > contains a msg_iov member that points to an array of scatter buffers, > as well as a msg_name pointer for the destination address. > > -- > James Carlson, Solaris Networking =A0 =A0 =A0 =A0 =A0 =A0 =A0<james.d.carl= ....@sun.com> > Sun Microsystems / 35 Network Drive =A0 =A0 =A0 =A071.232W =A0 Vox +1 781 = 442 2084 > MS UBUR02-212 / Burlington MA 01803-2757 =A0 42.496N =A0 Fax +1 781 442 16= 77 Many thanks to both of you! Best regards, Cristiano.
janesconference@gmail.com wrote: > Hi to everyone, I'd like to do a scattered write, like with writev() > on a Unix Domain Socket. The problem is, since the socket is of > SOCK_DGRAM type, and thus unconnected, writev will fail saying > "Transport endpoint is not connected". > I checked in the man pages and yes, write() and writev() will not work > on datagram-type sockets. Actually read(), write() will work on SOCK_DGRAM type sockets, if you call connect(). You lose the ability to communicate with more than one peer at the same time on the same socket, but you can now use the simpler read() and write() calls. Eventually writev() will also work after connect(). Rainer