Socket

Why

I wanted a single interface that would hide the inconsistencies among the various socket implementations.

I wanted to write network enabled software components once, and use them on any combination of operating system and hardware platform.

I wanted to afford other people this same luxury.


What

This is a thin socket wrapper (TCP and UDP) that compiles and runs on a number of platforms, including...

  • Windows
  • Linux
  • Cygwin
  • OSX
  • iOS (see Notes)

Socket provides only a rudimentary level of network communication.  It is not high level functionality like the kind you would get from NSURLConnection (for example), it is the foundation upon which you would build such functionality.


This is for anyone with an understanding of how TCP and UDP sockets work (BSD, or win32), who is building or experimenting

with network features in their development.  Additionally the uninitiated, if both stubborn and ambitious, may find this a helpful learning tool.


Notes

On iOS there are special considerations when using socket level APIs.  Specifically, the OS will not activate the WAN unless you use a higher level Apple network API call first.  As a work-around, some people use an Apple API call to fetch a dummy URL to wake up the WAN. I can only speculate as to why Apple's engineers made this decision.  Perhaps one day they will expose an API for bringing the WAN up and down directly.  Until then, using low level sockets on iOS seems a bit dicey.


Download

The interface headers contain all the documentation you need about using this wrapper.  The the platform specific implementation files may contain a few comments on specifics to provide any clarification that seemed necessary.

source code: socket.zip


© Paul Glinker 2002 - 2016