#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ifaddrs.h>
#include <linux/if_link.h>
#include <regex>
#include <string>
#include "trace.h"
Go to the source code of this file.
|
int | ResolveHost (char const *host_in, in_addr &addr) |
| Convert a string hostname to a in_addr suitable for socket communication. More...
|
|
int | GetInterfaceForNetwork (char const *host_in, in_addr &addr) |
| Convert an IP address to the network address of the interface sharing the subnet mask. More...
|
|
int | ResolveHost (char const *host_in, int dflt_port, sockaddr_in &sin) |
| Convert a string hostname and port to a sockaddr_in suitable for socket communication. More...
|
|
int | TCPConnect (char const *host_in, int dflt_port, int64_t flags=0, int sndbufsiz=0) |
| Connect to a host on a given port. More...
|
|
Provides utility functions for connecting TCP sockets
Definition in file TCPConnect.hh.
int GetInterfaceForNetwork |
( |
char const * |
host_in, |
|
|
in_addr & |
addr |
|
) |
| |
|
inline |
Convert an IP address to the network address of the interface sharing the subnet mask.
- Parameters
-
| host_in | IP to resolve |
[out] | addr | in_addr object populated with resolved host |
- Returns
- 0 if success, -1 if gethostbyname fails, 2 if defaulted to 0.0.0.0 (No matching interfaces)
Definition at line 90 of file TCPConnect.hh.
int ResolveHost |
( |
char const * |
host_in, |
|
|
in_addr & |
addr |
|
) |
| |
|
inline |
Convert a string hostname to a in_addr suitable for socket communication.
- Parameters
-
| host_in | Name or IP of host to resolve |
[out] | addr | in_addr object populated with resolved host |
- Returns
- 0 if success, -1 if gethostbyname fails
Definition at line 42 of file TCPConnect.hh.
int ResolveHost |
( |
char const * |
host_in, |
|
|
int |
dflt_port, |
|
|
sockaddr_in & |
sin |
|
) |
| |
|
inline |
Convert a string hostname and port to a sockaddr_in suitable for socket communication.
- Parameters
-
| host_in | Name or IP of host to resolve |
| dflt_port | POrt to populate in output |
[out] | sin | sockaddr_in object populated with resolved host and port |
- Returns
- 0 if success, -1 if gethostbyname fails
Definition at line 184 of file TCPConnect.hh.
int TCPConnect |
( |
char const * |
host_in, |
|
|
int |
dflt_port, |
|
|
int64_t |
flags = 0 , |
|
|
int |
sndbufsiz = 0 |
|
) |
| |
|
inline |
Connect to a host on a given port.
- Parameters
-
host_in | Name or IP of the host to connect to |
dflt_port | Port to connect to |
flags | TCP flags to use for the socket |
sndbufsiz | Size of the send buffer. Set to 0 for automatic send buffer management |
- Returns
- File descriptor of connected socket.
Definition at line 243 of file TCPConnect.hh.