| Revision 2424,
1.2 KB
checked in by chris, 3 years ago
(diff) |
|
Change use of int to identify a socket type to the proper enum.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: Socket.h |
|---|
| 5 | // Purpose: Socket related stuff |
|---|
| 6 | // Created: 2003/07/31 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef SOCKET__H |
|---|
| 11 | #define SOCKET__H |
|---|
| 12 | |
|---|
| 13 | #ifdef WIN32 |
|---|
| 14 | #include "emu.h" |
|---|
| 15 | typedef int socklen_t; |
|---|
| 16 | #else |
|---|
| 17 | #include <sys/socket.h> |
|---|
| 18 | #include <netinet/in.h> |
|---|
| 19 | #include <sys/un.h> |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | #include <string> |
|---|
| 23 | |
|---|
| 24 | typedef union { |
|---|
| 25 | struct sockaddr sa_generic; |
|---|
| 26 | struct sockaddr_in sa_inet; |
|---|
| 27 | #ifndef WIN32 |
|---|
| 28 | struct sockaddr_un sa_unix; |
|---|
| 29 | #endif |
|---|
| 30 | } SocketAllAddr; |
|---|
| 31 | |
|---|
| 32 | // -------------------------------------------------------------------------- |
|---|
| 33 | // |
|---|
| 34 | // Namespace |
|---|
| 35 | // Name: Socket |
|---|
| 36 | // Purpose: Socket utilities |
|---|
| 37 | // Created: 2003/07/31 |
|---|
| 38 | // |
|---|
| 39 | // -------------------------------------------------------------------------- |
|---|
| 40 | namespace Socket |
|---|
| 41 | { |
|---|
| 42 | enum Type |
|---|
| 43 | { |
|---|
| 44 | TypeINET = 1, |
|---|
| 45 | TypeUNIX = 2 |
|---|
| 46 | }; |
|---|
| 47 | |
|---|
| 48 | void NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, |
|---|
| 49 | enum Type type, const std::string& rName, int Port, |
|---|
| 50 | int &rSockAddrLenOut); |
|---|
| 51 | void LogIncomingConnection(const struct sockaddr *addr, socklen_t addrlen); |
|---|
| 52 | std::string IncomingConnectionLogMessage(const struct sockaddr *addr, socklen_t addrlen); |
|---|
| 53 | }; |
|---|
| 54 | |
|---|
| 55 | #endif // SOCKET__H |
|---|
| 56 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.