UCommon

ucommon/socket.h File Reference

Common socket class and address manipulation. More...

#include <ucommon/timers.h>
#include <ucommon/linked.h>
#include <ucommon/string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <ucommon/timers.h>
#include <ucommon/string.h>
#include <netdb.h>
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  cidr
 A class to hold internet segment routing rules. More...
struct  hostaddr_internet
 An object that holds ipv4 or ipv6 binary encoded host addresses. More...
class  ListenSocket
 A bound socket used to listen for inbound socket connections. More...
struct  sockaddr_internet
 An object that can hold a ipv4 or ipv6 socket address. More...
class  Socket
 A generic socket base class. More...
class  Socket::address
 A generic socket address class. More...
class  TCPServer
 A generic tcp server class. More...

Defines

#define DCCP_SOCKOPT_AVAILABLE_CCIDS   12
#define DCCP_SOCKOPT_CCID   13
#define DCCP_SOCKOPT_RX_CCID   15
#define DCCP_SOCKOPT_TX_CCID   14
#define DEFAULT_FAMILY   AF_INET
#define IPPROTO_DCCP   23
#define IPTOS_LOWDELAY   0x10
#define IPTOS_MINCOST   0x02
#define IPTOS_RELIABILITY   0x04
#define IPTOS_THROUGHPUT   0x08
#define SOCK_DCCP   6
#define SOL_DCCP   269

Typedefs

typedef struct hostaddr_internet inethostaddr_t
 An object that holds ipv4 or ipv6 binary encoded host addresses.
typedef struct sockaddr_internet inetsockaddr_t
 An object that can hold a ipv4 or ipv6 socket address.
typedef Socket socket
 A convenience class for socket.
typedef TCPServer tcpserv_t

Functions

struct sockaddr * addr (socket::address &address)
 A convenience function to convert a socket address list into a socket address.
struct addrinfo * addrinfo (socket::address &address)
 A convenience function to convert a socket address list into an addrinfo.
bool eq (struct sockaddr_storage *s1, struct sockaddr_storage *s2)
 Compare two stored socket addresses to see if equal.
bool eq (struct sockaddr *s1, struct sockaddr *s2)
 Compare two socket addresses to see if equal.
bool ieq (struct sockaddr *s1, struct sockaddr *s2)
 Compare two host addresses to see if equal.
String str (Socket &so, strsize_t size)

Detailed Description

Common socket class and address manipulation.

This offers a common socket base class that exposes socket functionality based on what the target platform supports. Support for multicast, IPV6 addressing, and manipulation of cidr policies are all supported here.

Definition in file socket.h.


Typedef Documentation

An object that can hold a ipv4 or ipv6 socket address.

This would be used for tcpip socket connections. We do not use sockaddr_storage because it is not present in pre ipv6 stacks, and because the storage size also includes the size of the path of a unix domain socket on posix systems.


Function Documentation

struct sockaddr* addr ( socket::address address) [read]

A convenience function to convert a socket address list into a socket address.

Parameters:
addresslist object.
Returns:
first socket address in list or NULL if empty.

Definition at line 1759 of file socket.h.

Here is the call graph for this function:

struct addrinfo* addrinfo ( socket::address address) [read]

A convenience function to convert a socket address list into an addrinfo.

Parameters:
addresslist object.
Returns:
addrinfo list or NULL if empty.

Definition at line 1750 of file socket.h.

Here is the call graph for this function:

bool eq ( struct sockaddr_storage *  s1,
struct sockaddr_storage *  s2 
) [inline]

Compare two stored socket addresses to see if equal.

If the port is zero then this is the same as comparing host address alone.

Parameters:
s1stored socket address to compare.
s2stored socket address to compare.
Returns:
true if addresses same.

Definition at line 1779 of file socket.h.

Here is the call graph for this function:

bool eq ( struct sockaddr *  s1,
struct sockaddr *  s2 
) [inline]

Compare two socket addresses to see if equal.

If the port is zero then this is the same as comparing host address alone.

Parameters:
s1socket address to compare.
s2socket address to compare.
Returns:
true if addresses same.
Examples:
cipher.cpp, datetime.cpp, digest.cpp, shell.cpp, and string.cpp.

Definition at line 1769 of file socket.h.

Here is the call graph for this function:

bool ieq ( struct sockaddr *  s1,
struct sockaddr *  s2 
) [inline]

Compare two host addresses to see if equal.

The port numbers are ignored.

Parameters:
s1socket address to compare.
s2socket address to compare.
Returns:
true if addresses same.
Examples:
keydata.cpp, and string.cpp.

Definition at line 1789 of file socket.h.

Here is the call graph for this function: