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
Unix domain socket?
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.
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 email@example.com.
For more options, visit https://groups.google.com/groups/opt_out.