Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
socket.cpp File Reference
#include "syssocket.h"
#include "socket.h"
#include "sysstring.h"
#include "exception.h"
#include "lexfn.h"
#include "postime.h"
#include <errno.h>
#include <pthread.h>
+ Include dependency graph for socket.cpp:

Functions

int addr_getport (_addr *addr)
bool addr_is_any (_addr *addr)
bool addr_is_ipv4 (_addr *a)
bool addr_is_ipv6 (_addr *a)
bool addr_is_none (_addr *addr)
void addr_setport (_addr *addr, int port)
std::string addr_to_string (const _addr *addr, bool include_port)
bool address_lookup (_addr *res, const char *name, int port)
bool address_matches (_addr *addr1, _addr *addr2)
bool addrport_matches (_addr *addr1, _addr *addr2)
unsigned char * get_ipv4_ptr (_addr *a)
unsigned char * get_ipv6_ptr (_addr *a)
void getaddress (_addr *res, const char *ip, int port)
void getaddress_ip4 (_addr *res, const unsigned char *ipv4_data, int port)
void getaddress_ip6 (_addr *res, const unsigned char *ipv6_data, int port)
int getprotocolbyname (const char *name)
 returns the internet protocol ID from name
int getserviceportbyname (const char *name)
 returns the internet service port from name
void setnonblock (int sockid)
bool sock_is_ipv4 (_addr *a)
bool sock_is_ipv6 (_addr *a)
int struct_len (_addr *addr)
int struct_pf (_addr *addr)
int tcpaccept (int socket, _addr *askaddr)
void tcpclose (int socket)
int tcpcreateserver (_addr *socketaddr)
bool tcpisopen (int sockid)
int tcpopen (_addr *addr)
int tcpopen_from (_addr *to, _addr *source)
int tcpread (int socket, const char *buff, int bufflen)
void tcpreadall (int sockid, const char *buff, int len, int maxtime)
int tcpsend (int socket, const char *buff, int bufflen)
void tcpsendall (int sockid, const char *buff, int len, int maxtime)
void udpclose (int sockid)
int udpcreateserver (_addr *socketaddr)
int udpread (int sockid, const char *buff, int len, _addr *addr)
void udpsend (int sockid, const char *buff, int len, _addr *addr)

Variables

bool posclient_quitflag = false

Function Documentation

int addr_getport ( _addr addr)

Gets the port of an _addr structure.

bool addr_is_any ( _addr addr)
bool addr_is_ipv4 ( _addr a)

Checks whether the address is an IPv6 address.

bool addr_is_ipv6 ( _addr a)

Checks whether the address is an IPv4 address.

bool addr_is_none ( _addr addr)

Returns true if the given address is the IPv4 any address

void addr_setport ( _addr addr,
int  port 
)

Sets the port of an _addr structure.

std::string addr_to_string ( const _addr addr,
bool  include_port = true 
)

Converts the _addr structure to a human-readable string.

bool address_lookup ( _addr res,
const char *  name,
int  port 
)

Looks up the specified domain name using the system resolver, and creates an _addr structure.

bool address_matches ( _addr a1,
_addr a2 
)

Checks whether both _addr structures point to the same address.

bool addrport_matches ( _addr a1,
_addr a2 
)

Checks whether both _addr structures point to the same address and port.

unsigned char* get_ipv4_ptr ( _addr a)

Returns pointer to the four bytes of the IPv4 address.

unsigned char* get_ipv6_ptr ( _addr a)

Returns true if the given address is the IPv4 none address Returns pointer to the sixteen bytes of the IPv6 address.

void getaddress ( _addr res,
const char *  data,
int  port = 0 
)

Converts an textual address (either IPv4/IPv6) to an _addr structure.

void getaddress_ip4 ( _addr res,
const unsigned char *  ipv4_data,
int  port = 0 
)

Converts an IPv4 binary address to an _addr structure.

void getaddress_ip6 ( _addr res,
const unsigned char *  ipv6_data,
int  port = 0 
)

Converts an IPv6 binary address to an _addr structure.

int getprotocolbyname ( const char *  name)

returns the internet protocol ID from name

Uses the system's getprotobyname() function to look up the service ID for a given protocol (usually, "udp" or "tcp"). Additionally, if the given string is a number, it will return that number.

Parameters
nameThe protocol name
Returns
The internet protocol ID
int getserviceportbyname ( const char *  name)

returns the internet service port from name

Uses the system's getservbyname() function to look up the port for a given service (for example, "http" or "ftp"). Additionally, if the given string is a number, it will return that number.

Parameters
nameThe service name
Returns
The service port
void setnonblock ( int  sockid)
bool sock_is_ipv4 ( _addr a)

Checks whether the address is an IPv6 address (obsolete, use addr_is_ipv4).

bool sock_is_ipv6 ( _addr a)

Checks whether the address is an IPv4 address (obsolete, use addr_is_ipv6).

int struct_len ( _addr addr)
int struct_pf ( _addr addr)
int tcpaccept ( int  sockid,
_addr addr 
)

Accepts a client connection on a TCP server connection.

void tcpclose ( int  sockid)

Closes a TCP client/server connection.

int tcpcreateserver ( _addr a)

Opens a TCP server at the specified address/port, returning the socket id.

bool tcpisopen ( int  sockid)

Checks whether the TCP connection is still open.

int tcpopen ( _addr a)

Opens a TCP client connection to the specified server.

int tcpopen_from ( _addr to,
_addr source 
)

Opens a TCP client coonection to the specified server from the specificed source address.

int tcpread ( int  sockid,
const char *  buff,
int  len 
)

Reads data from the TCP connection. Doesn't guarantee all data is read, but returns immediately.

void tcpreadall ( int  sockid,
const char *  buff,
int  len,
int  maxtime 
)

Reads len bytes through the TCP connection. Take at most maxtime milliseconds.

int tcpsend ( int  sockid,
const char *  buff,
int  len 
)

Sends data through the TCP connection. Doesn't guarantee all data is sent, but returns immediately.

void tcpsendall ( int  sockid,
const char *  buff,
int  len,
int  maxtime 
)

Sends all data through the TCP connection. Take at most maxtime milliseconds.

void udpclose ( int  sockid)

Closes an UDP connection, both server and client.

int udpcreateserver ( _addr a)

Opens an UDP server at the specified address/port, returning the socket id.

int udpread ( int  sockid,
const char *  buff,
int  len,
_addr addr 
)

Reads data from an UDP connection. The address of the sender is put in addr.

void udpsend ( int  sockid,
const char *  buff,
int  len,
_addr addr 
)

Sends data to the specified server through UDP.

Variable Documentation

bool posclient_quitflag = false

Set to true if you want to close down your application when sockets might still be active.