Main Page | Modules | Data Structures | File List | Data Fields

Networking


Defines

#define u_net_write(sd, buf, nbytes, nw, iseof)   u_net_io((iof_t) write, sd, buf, nbytes, nw, iseof)
 u_net_io specialisation for output ops

Functions

int u_net_sock (const char *uri, int mode)
 Top level socket creation routine.
int u_net_io (iof_t f, int sd, void *buf, size_t l, ssize_t *n, int *eof)
 Top level I/O routine.

Function Documentation

int u_net_io iof_t  f,
int  sd,
void *  buf,
size_t  l,
ssize_t *  n,
int *  eof
 

Try to read/write - atomically - a chunk of l bytes from/to the object referenced by the descriptor sd. The data chunk is written to/read from the buffer starting at buf. The I/O driver function f is used to carry out the job, its interface and behaviour must conform to those of POSIX.1 read() or write(). If n is not NULL, it will store the number of bytes actually read/written: this information is significant only when u_net_io has failed. If eof is not NULL, it will be set to 1 on an end-of-file condition.

Parameters:
f the I/O function, i.e. read(2) or write(2)
sd the file descriptor on which the I/O operation is performed
buf the data chunk to be read or written
l the length in bytes of buf
n the number of bytes read/written as a value-result arg
eof true if end-of-file condition
Returns:
A ~0 is returned if an error other than EINTR or EAGAIN has occurred, or if the requested amount of data could not be entirely read/written. A 0 is returned on success.

Definition at line 440 of file net.c.

int u_net_sock const char *  uri,
int  mode
 

This routine creates a socket and returns its file descriptor. A client socket (U_NET_CSOCK) is identified by its connection endpoint, a server socket (U_NET_SSOCK) by its local address.

The identification is done via a family of private URIs:

  • {tc,ud}p[46]://<host>:<port> for TCP/UDP over IPv[46] addresses,
  • unix://<abs_path> for UNIX IPC pathnames.

After resolving the supplied URI, the control is passed to the appropriate handler which carries out the real job (i.e. connect(2) or bind(2)). Per-protocol handlers can be used in combination with the URI resolver and translation functions for greater flexibility.

See also:
u_net_tcp4_ssock, u_net_tcp6_ssock, u_net_tcp4_csock, u_net_tcp6_csock, u_net_uri2addr, u_net_uri2sin, u_net_uri2sun.
Parameters:
uri the URI at which the socket shall be connected/bounded
mode U_NET_SSOCK for server sockets, U_NET_CSOCK for clients.
Returns:
  • the socket descriptor on success
  • -1 on failure

Definition at line 55 of file net.c.


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved