libporty - the net package
This package provides low level networking calls for creating sockets
and network connections, synchronous dns resolving and polling for
socket activity.
The networking and communication model of libporty is simple:
sockets are all equivalent and any stream I/O is a socket
(see net_async package for more details
on how stdio or background processes are converted to sockets). The user
may create multiple sockets and a poll call is provided and to wait for
activity on one or more sockets. The user application is single threaded
asynchronous normally.
Sockets are of type P_net_socket. The caller should not rely on this
type to be an integer. A macro P_NET_INVALID_SOCKET is defined; if
a socket is == P_NET_INVALID_SOCKET, the socket is invalid (or unused).
Before using the network layer, the application must call P_net_init().
Before exiting, P_net_uninit() shall be called.
libporty/net/network.h
API for the core functionality is implemented in network.h (and
in turn in os_dep.h).
The following enum constants are used with some of the calls:
enum
| level
| summary
|
P_net_err
| low
| error code (typically used as return value)
|
P_net_nonblock_t
| low
| controls whether sockets operations should be non-blocking, for some of the calls
|
P_net_broadcast_t
| low
| controls whether sockets shold allow broadcasting
|
libporty/net/local.h
Libporty components often communicate with eachother over local sockets.
This component can create a local socket pair, which is an anonymous
socket on UNIX and a local network (usully TCP) connection on platforms
that do not support that.
libporty/net/dns4.h
Synchronous (blocking) dns lookups for TCP/IP v4. Terminology: name
is a textual hostname; addr is an IP address as text and IP
is binary IP address represented as a 32-bit unsigned long int.
libporty/net/tcp4.h
Simplified (and portable) API for TCP/IPv4. The basic features of
listening for incoming connections, connect to remote host are implemented.
libporty/net/udp4.h
Simplified (and portable) API for UDP/IPv4.