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

Networking

#define u_net_write(sd, buf, nbytes, nw, iseof)   u_io((iof_t) write, sd, buf, nbytes, nw, iseof)
 u_io specialisation for output ops
#define u_net_read(sd, buf, nbytes, nw, iseof)   u_io(read, sd, buf, nbytes, nw, iseof)
 u_io specialisation for input ops
#define u_net_writen(sd, buf, nbytes)   u_io((iof_t) write, sd, buf, nbytes, 0, 0)
 Try to write a chunk of nbytes data to descriptor sd.
#define u_net_readn(sd, buf, nbytes)   u_io(read, sd, buf, nbytes, 0, 0)
 Try to read a chunk of nbytes data from descriptor sd.

Functions

int u_net_sock (const char *uri, int mode)
 Top level socket creation routine.
int u_net_sock_tcp (u_net_addr_t *a, int mode)
int u_net_sock_unix (u_net_addr_t *a, int mode)
int u_net_unix_csock (struct sockaddr_un *sad)
int u_net_unix_ssock (struct sockaddr_un *sad, int backlog)
int u_net_sock_udp (u_net_addr_t *a, int mode)
int u_net_tcp6_ssock (struct sockaddr_in6 *sad, int reuse, int backlog)
int u_net_tcp6_csock (struct sockaddr_in6 *sad)
int u_net_tcp4_ssock (struct sockaddr_in *sad, int reuse, int backlog)
int u_net_tcp4_csock (struct sockaddr_in *sad)
int u_net_uri2addr (const char *uri, u_net_addr_t **pa)
int u_net_uri2sun (const char *uri, struct sockaddr_un *sad)
int u_net_addr_new (int type, u_net_addr_t **pa)
void u_net_addr_free (u_net_addr_t *a)
int u_net_uri2sin (u_uri_t *uri, struct sockaddr_in *sad)

Function Documentation

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.

References u_net_addr_s::type, u_net_addr_free(), u_net_sock_tcp(), u_net_sock_unix(), and u_net_uri2addr().


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