Helper class for initialization and cleanup of network usage.
More...
#include <NetworkHelper.h>
|
| NetworkHelper () |
| Constructor. Calls WSAStartup on Windows.
|
|
virtual | ~NetworkHelper () |
| Destructor. Calls WSACleanup on Windows in case of successful WSAStartup.
|
|
|
static SOCKET | Connect (sockaddr_storage *sockaddr, socklen_t *addrlen, const std::string &address, uint16_t port) |
| Connect to a remote machine. More...
|
|
static SOCKET | Bind (sockaddr_storage *sockaddr, socklen_t *addrlen, const std::string &address, uint16_t port) |
| Bind on a local address. More...
|
|
Helper class for initialization and cleanup of network usage.
On Windows WSAStartup is called within constructor and WSACleanup within destructor. Define DAVID_EXTERNAL_WSA_STARTUP, if you want to call WSAStartup externally.
Definition at line 68 of file NetworkHelper.h.
static SOCKET david::NetworkHelper::Bind |
( |
sockaddr_storage * |
sockaddr, |
|
|
socklen_t * |
addrlen, |
|
|
const std::string & |
address, |
|
|
uint16_t |
port |
|
) |
| |
|
static |
Bind on a local address.
- Parameters
-
[out] | sockaddr | Gets the sockaddr if the function succeeds. |
[out] | addrlen | Length of sockaddr if the functions succeeds. |
[in] | address | Remote address. |
[in] | port | Remote port. |
- Returns
- Socket descriptor if successful, -1 otherwise.
static SOCKET david::NetworkHelper::Connect |
( |
sockaddr_storage * |
sockaddr, |
|
|
socklen_t * |
addrlen, |
|
|
const std::string & |
address, |
|
|
uint16_t |
port |
|
) |
| |
|
static |
Connect to a remote machine.
- Parameters
-
[out] | sockaddr | Gets the sockaddr if the function succeeds. |
[out] | addrlen | Length of sockaddr if the functions succeeds. |
[in] | address | Remote address. |
[in] | port | Remote port. |
- Returns
- Socket descriptor if successful, -1 otherwise.
The documentation for this class was generated from the following file: