[Haskell-cafe] Issue with "connectTo" function in "network" package

aditya siram aditya.siram at gmail.com
Fri Jun 4 16:14:04 EDT 2010


Great! If there is a wiki or FAQ page for networking with Haskell it
might be worth updating.
-deech

On 6/4/10, Roman Cheplyaka <roma at ro-che.info> wrote:
> /etc/hosts is the file responsible for resolving 'localhost' hostname.
> As you can see from it, there are two entries for localhost: one
> contains IPv4 address (127.0.0.1) and another contains IPv6 address
> (::1).
>
> The behaviour you observe is kinda bug in connectTo function. Instead of
> trying all of the addresses, this function just tries the first one.
> Until it is fixed (I'm gonna write and send a patch soon), can you live
> with this temporary hack? If for some reason the answer is "no", you
> have to use low-level functions from Network.Socket module for now.
>
>
> * aditya siram <aditya.siram at gmail.com> [2010-06-04 14:15:47-0500]
>> Doing (1) solves my problem. What did I do and why did it work? Thanks
>> a lot for your help!
>> -deech
>>
>> On 6/4/10, Roman Cheplyaka <roma at ro-che.info> wrote:
>> > Confirm if any of the following solves the problem:
>> >
>> > 1. commenting out (by prepending putting hash sign '#' in the beginning
>> >    of the line) the following line in /etc/hosts:
>> >
>> > ::1     localhost ip6-localhost ip6-loopback
>> >
>> > 2. executing as root the following command:
>> >
>> > rmmod ipv6
>> >
>> > * aditya siram <aditya.siram at gmail.com> [2010-06-04 13:51:29-0500]
>> >> Here's my GHCI session (with my network card off):
>> >> Prelude Network Network.Socket> connectTo "localhost" (PortNumber 3000)
>> >> *** Exception: connect: does not exist (Connection refused)
>> >> Prelude Network Network.Socket> connectTo "127.0.0.1" (PortNumber 3000)
>> >> {handle: <socket: 7>}
>> >>
>> >> The OS is Ubuntu (Lucid) Linux. The contents of "/etc/hosts" and
>> >> "/etc/nsswitch.conf" are:
>> >>
>> >> > cat /etc/nsswitch.conf
>> >> # /etc/nsswitch.conf
>> >> #
>> >> # Example configuration of GNU Name Service Switch functionality.
>> >> # If you have the `glibc-doc-reference' and `info' packages installed,
>> >> try:
>> >> # `info libc "Name Service Switch"' for information about this file.
>> >>
>> >> passwd:         compat
>> >> group:          compat
>> >> shadow:         compat
>> >>
>> >> hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
>> >> networks:       files
>> >>
>> >> protocols:      db files
>> >> services:       db files
>> >> ethers:         db files
>> >> rpc:            db files
>> >>
>> >> netgroup:       nis
>> >>
>> >> > cat /etc/hosts
>> >> 127.0.0.1       localhost
>> >> 127.0.1.1       deech-mac-ubuntu
>> >>
>> >> # The following lines are desirable for IPv6 capable hosts
>> >> ::1     localhost ip6-localhost ip6-loopback
>> >> fe00::0 ip6-localnet
>> >> ff00::0 ip6-mcastprefix
>> >> ff02::1 ip6-allnodes
>> >> ff02::2 ip6-allrouters
>> >> ff02::3 ip6-allhosts
>> >>
>> >>
>> >> -deech
>> >>
>> >> On 6/4/10, Roman Cheplyaka <roma at ro-che.info> wrote:
>> >> > * aditya siram <aditya.siram at gmail.com> [2010-06-03 22:30:33-0500]
>> >> >> Hi all,
>> >> >> I had an issue where using the connectTo [1] function would fail to
>> >> >> connect to "localhost" if my wireless card was turned off. The
>> >> >> moment
>> >> >> I turned on my wireless connection it worked. But if I use connectTo
>> >> >> with "127.0.0.1" [2] with my network off it works.
>> >> >>
>> >> >> I confirmed that "localhost' resolves to "127.0.0.1" by pinging
>> >> >> "localhost" from command line with the Internet off.
>> >> >>
>> >> >> Is this a bug in "connectTo"?
>> >> >>
>> >> >> -deech
>> >> >>
>> >> >> [1] connectTo "localhost" (PortNumber some_number)
>> >> >> [2] connectTo "127.0.0.1" (PortNumber some_number)
>> >> >
>> >> > How exactly did it fail? Did it throw an exception? If so, what was
>> >> > the
>> >> > exception?
>> >> >
>> >> > Which operating system did you observe that under?
>> >> >
>> >> > If that was Linux, can you show the contents of the following files
>> >> > on
>> >> > that system:
>> >> >
>> >> > /etc/nsswitch.conf
>> >> > /etc/hosts
>> >> >
>> >> > --
>> >> > Roman I. Cheplyaka :: http://ro-che.info/
>> >> > "Don't let school get in the way of your education." - Mark Twain
>> >> > _______________________________________________
>> >> > Haskell-Cafe mailing list
>> >> > Haskell-Cafe at haskell.org
>> >> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >> >
>> >
>> > --
>> > Roman I. Cheplyaka :: http://ro-che.info/
>> > "Don't let school get in the way of your education." - Mark Twain
>> >
>
> --
> Roman I. Cheplyaka :: http://ro-che.info/
> "Don't let school get in the way of your education." - Mark Twain
>


More information about the Haskell-Cafe mailing list