Ticket #2998 (closed proposal: fixed)

Opened 4 years ago

Last modified 4 years ago

Expose the internals of the network library to make it more extensible

Reported by: tibbe Owned by: igloo
Priority: normal Milestone: Not GHC
Component: libraries (other) Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When creating new libraries on top of the network library it would be convenient if the library exposed some functions that hide platform variations so that the new libraries can be written in a portable manner.

Take for example the currently un-exported pokeSockAddr function which marshalls a SockAddr into a sockaddr struct. This function would be useful when e.g. writing a binding for the sendmsg system call. However, it's not exported so libraries are forced to define their own version.

This is unfortunate. I propose we add a new module, Network.Socket.Internal, to the network library, that exposes these portable marshalling functions. It might also be a good idea to expose some internal data representations in the same way bytestring currently does. People who write code that uses this internal do so knowing that there is a risk that the interface and data representations might change.

I've written a patch that exposes some of the library's internal functions. There are still some documentation to write and perhaps a few more functions to expose but I think we should reach consensus on whether this is a good idea to begin with before continuing.

Since this change isn't disruptive I propose a two week consideration deadline.

Cabal package:

 http://johantibell.com/network-2.2.1.tar.gz

Haddock:

 http://johantibell.com/network/doc/html/network/

Attachments

internal.patch Download (16.8 KB) - added by tibbe 4 years ago.
expose-socket-internals-in-a-new-module_.dpatch Download (45.2 KB) - added by tibbe 4 years ago.
New Network.Socket.Internal module
move-the-throwsocketerror_-class-of-functions-into-the-internals-module_.dpatch Download (19.7 KB) - added by tibbe 4 years ago.

Change History

Changed 4 years ago by tibbe

Changed 4 years ago by igloo

  • difficulty set to Unknown
  • component changed from libraries/base to libraries (other)
  • milestone set to Not GHC

Changed 4 years ago by felixmar

I support this proposal. Please also include sizeOfSockAddr_Family in the Network.Socket.Internal module.

Changed 4 years ago by tibbe

As there were no objections during the discussion period I will go ahead and implement this proposal. I will try to release a new version of network as soon as feasible.

Changed 4 years ago by tibbe

New Network.Socket.Internal module

Changed 4 years ago by tibbe

  • owner set to igloo

All four patches that make up the new module are in expose-socket-internals-in-a-new-module_.dpatch. That file subsumes internal.patch.

I would like to make a new release of the library as soon as possible as I have a second library I want to release that needs these changes. What can I do to help with the release process?

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Applied, thanks!

Changed 4 years ago by tibbe

  • status changed from closed to reopened
  • resolution fixed deleted

I've attached two more patches (see move-the-throwsocketerror_-class-of-functions-into-the-internals-module_.dpatch) that expose the throwSocketErrorIf* class of functions. The patch is split in two for easier reviewing. The first patch simply moves the functions to the Internal module. The second renames some of them and adds documentation.

I've tested this on Mac OS X 10.5 and Windows (using MinGW/MSYS).

Changed 4 years ago by tibbe

  • status changed from reopened to new

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

tibbe says that this has been done now, with .Internal.

Note: See TracTickets for help on using tickets.