jabberd14 1.6.2
Functions
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:
hostthe 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:
portport number of the socket
hosthostname where to connect to or listen on
typetype 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:
servnamethe service name (currently this has to be a numeric port number)
nodenamethe hostname where to connect to or listen on
typetype of socket (NETSOCKET_SERVER, NETSOCKET_CLIENT, or NETSOCKET_UDP)
Returns:
file handle of the new socket (-1 or error)

References make_netsocket().