EHS Embedded HTTP Server
1.5.1.0
|
30 # pragma warning(disable : 4786)
33 #ifdef HAVE_WINSOCK2_H
34 # include <winsock2.h>
42 #ifdef HAVE_NETINET_IN_H
43 # include <netinet/in.h>
45 #ifdef HAVE_SYS_TYPES_H
46 # include <sys/types.h>
48 #ifdef HAVE_SYS_SOCKET_H
49 # include <sys/socket.h>
51 #ifdef HAVE_SYS_IOCTL_H
52 # include <sys/ioctl.h>
57 #ifdef HAVE_ARPA_INET_H
58 # include <arpa/inet.h>
64 typedef unsigned long in_addr_t;
65 typedef size_t socklen_t;
66 # define sleep(seconds) (Sleep(seconds * 1000))
69 extern const char *net_strerror();
71 # define net_errno WSAGetLastError()
73 # define INVALID_SOCKET -1
74 # define net_errno errno
77 #include "networkabstraction.h"
94 Socket(ehs_socket_t fd, sockaddr_in *peer);
105 virtual void Init(
int port);
113 virtual int Read(
void *buf,
int bufsize);
115 virtual int Send(
const void *buf,
size_t buflen,
int flags = 0);
117 virtual void Close();
std::string GetRemoteAddress() const
Retrieves the peer address.
virtual void RegisterBindHelper(PrivilegedBindHelper *helper)
Registers a PrivilegedBindHelper for use by this instance.
int GetRemotePort() const
Retrieves the peer's port of a connection.
virtual void Init(int port)
Initializes a listening socket.
virtual int Send(const void *buf, size_t buflen, int flags=0)
Performs a send on the underlying socket.
virtual NetworkAbstraction * Accept()
Waits for an incoming connection.
virtual void SetBindAddress(const char *bindAddress)
Sets the bind address of the socket.
ehs_socket_t m_fd
The file descriptor of the socket on which this connection came in.
sockaddr_in m_peer
Stores the peer address of the current connection.
virtual void Close()
Closes the underlying socket.
std::string GetLocalAddress() const
Retrieves the peer address.
plain socket implementation of NetworkAbstraction
virtual bool IsSecure() const
Determines, whether the underlying socket is secure.
sockaddr_in m_bindaddr
Stores the bind address.
virtual int Read(void *buf, int bufsize)
Performs a read from the underlying socket.
Helper class for binding of sockets to privileged ports.
PrivilegedBindHelper * m_pBindHelper
Our bind helper.
Abstracts different socket types.
std::string GetPeer() const
Combination of GetRemoteAddress and GetRemotePort.
virtual ehs_socket_t GetFd() const
Retrieves the underlying file descriptor.
virtual void ThreadCleanup()
Handles thread specific clean up (used by OpenSSL).
Socket()
Default constructor.
int GetLocalPort() const
Retrieves the peer's port of a connection.