FAQ
If I Accept a connection from a UnixListener created with

net.ListenUnix("unix", &net.UnixAddr{sockName, "unixpacket"})


is a Read from that connection guaranteed to read a complete message
(assuming it fits in the buffer)?

If not, then what's the correct way to read a complete message from a
unixpacket listener?

Thanks,
— Scott

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Matt Harden at Jan 10, 2015 at 3:13 am
    I don't think net.ListenUnix will use the Net portion of the address. The
    call you listed will give you a stream-oriented socket, which doesn't have
    a concept of message boundaries, so no, it won't guarantee to return a
    complete anything.

    If you want to use a unix packet-oriented connection I would use
    net.Listen("unixpacket", sockName).(net.UnixListener) to create the
    listener, use AcceptUnix to accept the connections, and then ReadFrom to
    read the packets. I believe that Read would also guarantee to read full
    packets if they fit in the buffer, even though the package docs don't make
    this clear. If the packet does not fit, the trailing excess data will be
    discarded. There is never a "partial" packet ready to read on a socket.
    On Wed Jan 07 2015 at 3:23:34 PM Scott Pakin wrote:

    If I Accept a connection from a UnixListener created with

    net.ListenUnix("unix", &net.UnixAddr{sockName, "unixpacket"})


    is a Read from that connection guaranteed to read a complete message
    (assuming it fits in the buffer)?

    If not, then what's the correct way to read a complete message from a
    unixpacket listener?

    Thanks,
    — Scott

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Scott Pakin at Jan 12, 2015 at 10:00 pm

    On Friday, January 9, 2015 at 8:13:34 PM UTC-7, Matt Harden wrote:
    I don't think net.ListenUnix will use the Net portion of the address. The
    call you listed will give you a stream-oriented socket, which doesn't have
    a concept of message boundaries, so no, it won't guarantee to return a
    complete anything.

    If you want to use a unix packet-oriented connection I would use
    net.Listen("unixpacket", sockName).(net.UnixListener) to create the
    listener, use AcceptUnix to accept the connections, and then ReadFrom to
    read the packets. I believe that Read would also guarantee to read full
    packets if they fit in the buffer, even though the package docs don't make
    this clear. If the packet does not fit, the trailing excess data will be
    discarded. There is never a "partial" packet ready to read on a socket.
    Helpful information; thanks.

    — Scott

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 7, '15 at 9:23p
activeJan 12, '15 at 10:00p
posts3
users2
websitegolang.org

2 users in discussion

Scott Pakin: 2 posts Matt Harden: 1 post

People

Translate

site design / logo © 2021 Grokbase