What is the best abstraction for network socket?

Submitted by jmuk on Thu, 07/27/2006 - 5:32am.

There are many stream like data structure proposed now. At first, the standard library already contains Network and Network.Socket. Network module expresses socket as a Handle and Network.Socket module does it as `Socket' type, which is not compatible with Handle.

Then, Streams and (http://haskell.org/haskellwiki/Library/Streams) and SSC are proposed (http://yogimo.sakura.ne.jp/ssc/). Which is more proper library?
Streams has no consideration about networking and SSC has. But, Socket of SSC is just an instance of BlockPort (using Ptr a), which is not a good abstraction for sockets, IMHO.
Is SSC better choise?

Then, I'd like to handle sockets with ByteString for performance reason. And I will have to deal with SSL/TLS using hsgnutls or such like libraries.

Now, HaskellNet is written by Network.Stream and Network.TCP originally came from HTTP. They are good abstraction about socket, but are not the best one when considering about ByteString-ization and SSL/TLS.

Please let me know about other implementation or consideration about this topic if you know.

Submitted by aljee on Mon, 07/31/2006 - 4:13am.

Hi, I'm the author of SSC. Unfortunately, SSC is not really ready to use for real applications yet, so I would not recommend you to use it for your library.

Some other points:

  • Streams is a extensible library, so you can add support for networking, even if the library contains no built-in support for it.
  • In SSC, you don't have to work with raw BlockPorts. You can apply port transformers to it, so that it can be used through the getLine/putStr interface (Streams library has this mechanism, too) . Currently there is no operation corresponding to HaskellNet.Stream.readBlock, but I'm planning to add one.

I hope this helps.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.