[Haskell-cafe] Re: Missing Network Functions

ChrisK haskell at list.mightyreason.com
Sun Dec 28 06:48:47 EST 2008


John Van Enk wrote:
> I want to group them with Network functions because traditionally these 
> specific functions *are* in networking packages.

I agree.  It is true that these functions are in the <arpa/inet.h> header on my 
machine.  The ntoh* and hton* are just data manipulation, just as Network.URI is 
  all about constructing and manipulating URI data.

The question I think we should answer is: Do we wish to follow the precedent of 
putting URI under Network and not Data?

Pragmatically, programmers will expect to find these functions near the 'net ones.

A "network-byteorder" package which has the "Network.ByteOrder" module is the 
most flexible thing to create.  It can be updated and reinstalled independently 
of the "network" package.

> 
> On *nix systems, the prototypes reside in <netinet/in.h>. On Windows 
> they reside in <winsock2.h> and one must link against libws2_32.
> 
> The package I have locally supports all platforms. It just does a 
> foreign import of the function (and uses a preprocessor definition to 
> pick the calling convention).
> 
> One could make an argument to add these sorts of functions to Word and 
> Int packages.
> 
> /jve
> 
> 
> On Sat, Dec 27, 2008 at 7:14 PM, Chris Kuklewicz 
> <haskell at list.mightyreason.com <mailto:haskell at list.mightyreason.com>> 
> wrote:
> 
>     Are these going to be available on Windows or just Posix systems?
> 
>     And these are NOT performing network communication.  They are bit
>     manipulations.
> 
>     I could imagine putting them in/under the Data.Word or Data.Bits
>     more than Network.*
> 
>     And they should also be made to work with the corresponding
>     Foreign.C.Types of CShort, etc.
> 
> 
>     John Van Enk wrote:
> 
>         While working on a project, I discovered that hton[sl] and
>         ntoh[sl] are missing from the networking libraries. It appears
>         there was some justification for this, but I've fallen upon a
>         few instances where things were *not* working as expected.
>         (Specifically when newtype'ing around HostAddress.)
> 
>         As such, I'm putting together a few extra functions that I think
>         should exist in Network somewhere. I'm calling the package
>         Network.Util (but am open to changes).
> 
>         Currently this only has:
> 
>            * htons
>            * htonl
>            * ntohs
>            * ntohl
> 
>         Before I drop this on hackage:
> 
>           1. Is there a reason I shouldn't do this?
>           2. Are there other suggestions for missing functions? (preferably
> 
>              cross-platform suggestions)
> 
>         Thanks all.
> 
>         /jve
> 
> 
>         ------------------------------------------------------------------------
> 
>         _______________________________________________
>         Haskell-Cafe mailing list
>         Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
>         http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list