Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket - Unix

This is a discussion on Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket - Unix ; 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". ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

  1. Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

    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.

  2. Re: Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

    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.

  3. Re: Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

    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
    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

  4. Re: Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

    On 6 Mag, 14:25, James Carlson 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()? *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 * * * * * * *
    > 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


    Many thanks to both of you!
    Best regards,

    Cristiano.

  5. Re: Scattered-write with sendto() un a SOCK_DGRAM Unix Domain Socket

    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

+ Reply to Thread