FAQ
The net package defines Listen, ListenUnix, Accept and AcceptUnix.

There are examples online establishing Unix domain socket connection using
Listen/Accept and ListenUnix/AcceptUnix. If those non-Unix calls are as
compatible as *Unix calls, then which one is the best fit to manipulating
Unix domain socket?

Thank you!

--
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/groups/opt_out.

Search Discussions

  • Gyepi SAM at Feb 17, 2014 at 7:58 am

    On Sun, Feb 16, 2014 at 11:06:52PM -0800, Howard Guo wrote:
    The net package defines Listen, ListenUnix, Accept and AcceptUnix.

    There are examples online establishing Unix domain socket connection using
    Listen/Accept and ListenUnix/AcceptUnix. If those non-Unix calls are as
    compatible as *Unix calls, then which one is the best fit to manipulating
    Unix domain socket?

    Thank you!
    Listen and Accept are just front ends for the more specific functions.

    They switch on the address types and call the more specific functions.

    It really makes no difference other than signaling intent and allowing for
    generalization. If you know you're only dealing with Unix sockets then it
    makes more sense to use their specific functions.

    -Gyepi


    --
    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/groups/opt_out.
  • Howard Guo at Feb 17, 2014 at 10:57 am
    Thanks very much Gyepi.
    On Monday, 17 February 2014 08:58:28 UTC+1, Gyepi SAM wrote:
    On Sun, Feb 16, 2014 at 11:06:52PM -0800, Howard Guo wrote:
    The net package defines Listen, ListenUnix, Accept and AcceptUnix.

    There are examples online establishing Unix domain socket connection using
    Listen/Accept and ListenUnix/AcceptUnix. If those non-Unix calls are as
    compatible as *Unix calls, then which one is the best fit to
    manipulating
    Unix domain socket?

    Thank you!
    Listen and Accept are just front ends for the more specific functions.

    They switch on the address types and call the more specific functions.

    It really makes no difference other than signaling intent and allowing for
    generalization. If you know you're only dealing with Unix sockets then it
    makes more sense to use their specific functions.

    -Gyepi

    --
    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/groups/opt_out.
  • Carlos Castillo at Feb 17, 2014 at 4:02 pm
    The other difference that's obvious looking at the api, is that the generic
    Dial/Listen/Accept methods take strings for addresses and other parameters,
    while the specific ones take types made to more directly represent the
    appropriate values. Also address resolution is always performed on string
    values, while you can specify "raw" IP addresses and other properties
    without parsing or address resolution.

    The advantage of the generic method is two fold:

        1. You often will only need 1 method to get the connection/listenener as
        the multiple steps needed to parse and lookup the addresses are done for you
        2. Strings are often easier to get from the user and store in a file

    The disadvantages are:

        1. Slower as parsing the string is always needed, and address lookups
        are also done "for you"
        2. The types of parameters to the specific functions/methods can give
        you easier / faster control of specific properties (eg: changing the port
        in a TCPAddr

    On Sunday, February 16, 2014 11:58:28 PM UTC-8, Gyepi SAM wrote:
    On Sun, Feb 16, 2014 at 11:06:52PM -0800, Howard Guo wrote:
    The net package defines Listen, ListenUnix, Accept and AcceptUnix.

    There are examples online establishing Unix domain socket connection using
    Listen/Accept and ListenUnix/AcceptUnix. If those non-Unix calls are as
    compatible as *Unix calls, then which one is the best fit to
    manipulating
    Unix domain socket?

    Thank you!
    Listen and Accept are just front ends for the more specific functions.

    They switch on the address types and call the more specific functions.

    It really makes no difference other than signaling intent and allowing for
    generalization. If you know you're only dealing with Unix sockets then it
    makes more sense to use their specific functions.

    -Gyepi

    --
    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/groups/opt_out.
  • Jesse McNelis at Feb 18, 2014 at 4:34 am

    On Tue, Feb 18, 2014 at 3:02 AM, Carlos Castillo wrote:

    The other difference that's obvious looking at the api, is that the
    generic Dial/Listen/Accept methods take strings for addresses and other
    parameters, while the specific ones take types made to more directly
    represent the appropriate values. Also address resolution is always
    performed on string values, while you can specify "raw" IP addresses and
    other properties without parsing or address resolution.

    The advantage of the generic method is two fold:

    1. You often will only need 1 method to get the connection/listenener
    as the multiple steps needed to parse and lookup the addresses are done for
    you
    2. Strings are often easier to get from the user and store in a file

    The main advantage is that the net.Listen() returns an interface.
    This means you can write your code against that interface and switch from
    using unix domain sockets to TCP by just changing a string.


    --
    =====================
    http://jessta.id.au

    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 17, '14 at 7:06a
activeFeb 18, '14 at 4:34a
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase