socket.cc File Reference

some misc functions to handle sockets More...

#include <jabberdlib.h>

Functions

int make_netsocket2 (Glib::ustring servname, Glib::ustring nodename, int type)
int make_netsocket (u_short port, char const *host, int type)
struct in_addr * make_addr (char const *host)

Detailed Description

some misc functions to handle sockets

Hint: after creating a socket with these function, you probably want to register this socket in mio using mio_new().


Function Documentation

struct in_addr* make_addr ( char const *  host  )  [read]

convert an IPv4 address or hostname to a in_addr structure

Parameters:
host the IPv4 address or hostname to convert, on NULL, the hostname is used
Returns:
the in_addr struct that holds the result (pointer to a static structure, overwritten on next call!)

References MAXHOSTNAMELEN.

Referenced by make_netsocket().

int make_netsocket ( u_short  port,
char const *  host,
int  type 
)

Simple wrapper to make socket creation easy.

Parameters:
port port number of the socket
host hostname where to connect to or listen on
type type of socket (NETSOCKET_SERVER, NETSOCKET_CLIENT; or NETSOCKET_UDP)
Returns:
file handle of the new socket (-1 or error)

References make_addr(), NETSOCKET_CLIENT, NETSOCKET_SERVER, and NETSOCKET_UDP.

Referenced by make_netsocket2(), and mio_listen().

int make_netsocket2 ( Glib::ustring  servname,
Glib::ustring  nodename,
int  type 
)

Simple wrapper to create sockets

Todo:
Currently servname has to be already numeric. It should be possible to provide service names that are resolved in /etc/services
Parameters:
servname the service name (currently this has to be a numeric port number)
nodename the hostname where to connect to or listen on
type type of socket (NETSOCKET_SERVER, NETSOCKET_CLIENT, or NETSOCKET_UDP)
Returns:
file handle of the new socket (-1 or error)

References make_netsocket().

Generated on Fri Sep 3 06:00:07 2010 for jabberd14 by  doxygen 1.6.3