diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-27 19:53:48 -0400 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-27 19:53:48 -0400 |
commit | 757294d769a7defe6a531a09fba9674cc6b388f7 (patch) | |
tree | ca47acead4e3676acd942de5f443d7bdc5fdd90c /lib/server/Socket.h |
Import boxbackup_0.11.1~r2837.orig.tar.gz
[dgit import orig boxbackup_0.11.1~r2837.orig.tar.gz]
Diffstat (limited to 'lib/server/Socket.h')
-rw-r--r-- | lib/server/Socket.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/server/Socket.h b/lib/server/Socket.h new file mode 100644 index 00000000..5034dbd8 --- /dev/null +++ b/lib/server/Socket.h @@ -0,0 +1,56 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: Socket.h +// Purpose: Socket related stuff +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- + +#ifndef SOCKET__H +#define SOCKET__H + +#ifdef WIN32 +#include "emu.h" +typedef int socklen_t; +#else +#include <sys/socket.h> +#include <netinet/in.h> +#include <sys/un.h> +#endif + +#include <string> + +typedef union { + struct sockaddr sa_generic; + struct sockaddr_in sa_inet; +#ifndef WIN32 + struct sockaddr_un sa_unix; +#endif +} SocketAllAddr; + +// -------------------------------------------------------------------------- +// +// Namespace +// Name: Socket +// Purpose: Socket utilities +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- +namespace Socket +{ + enum Type + { + TypeINET = 1, + TypeUNIX = 2 + }; + + void NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, + enum Type type, const std::string& rName, int Port, + int &rSockAddrLenOut); + void LogIncomingConnection(const struct sockaddr *addr, socklen_t addrlen); + std::string IncomingConnectionLogMessage(const struct sockaddr *addr, socklen_t addrlen); +}; + +#endif // SOCKET__H + |