extras/net: Fixes for the net library

This change fixes two problems with the net library in extras/.

The h_addr field of the hostent structure (see gethostbyname(3)) is
deprecated.  gethostbyname can return multiple addresses in a list in the
field h_addr_list.  I've updated code to use the first item in this list.
Note that use of gethostbyname is also discouraged and getaddrinfo(3) is
recommended.  In a later change I intend to update this library to use
getaddrinfo.

The library used a macro error() to retrieve the error either from errno, or
on Windows from WSAGetLastError.  WSAGetLastError is a function however the
parentheses were missing from the macro causing it to be returned as a value
rather than called.

extras/net/sockets.m:
extras/net/tcp.m:
    As above.
extras/net: Make sockets.m more thread safe

sockets.m:
    This file used a static C variable to store the most recent value of
    errno.  This has been removed and replaced with better return values
    making more calls thread safe.  Some non-thread safe calls still remain
    where the C library call itself is not thread safe.
extras/net: Document sockets.m

sockets.m:
    As above.