net.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. */
  6. #ifdef WIN32
  7. #define WIN32_LEAN_AND_MEAN
  8. #include <windows.h>
  9. #include <winsock.h>
  10. #else
  11. #include <sys/socket.h>
  12. #include <netinet/in.h>
  13. #include <arpa/inet.h>
  14. #include <unistd.h>
  15. #endif
  16. //#include <netdb.h>
  17. #include <errno.h>
  18. #include <fcntl.h>
  19. #include "../common/types.h"
  20. void CatchSignal(int sig_num);
  21. enum eServerMode { Standalone, Master, Slave, Mesh };
  22. class NetConnection
  23. {
  24. public:
  25. NetConnection() {
  26. port = 5999;
  27. listening_socket = 0;
  28. memset(masteraddress, 0, sizeof(masteraddress));
  29. uplinkport = 0;
  30. memset(uplinkaccount, 0, sizeof(uplinkaccount));
  31. memset(uplinkpassword, 0, sizeof(uplinkpassword));
  32. LoginMode = Standalone;
  33. Uplink_WrongVersion = false;
  34. numclients = 0;
  35. numservers = 0;
  36. }
  37. void UpdateWindowTitle(char* iNewTitle = 0);
  38. bool Init();
  39. void ListenNewClients();
  40. void HitKey(int keyhit);
  41. char address[1024];
  42. int32 numclients;
  43. int32 numservers;
  44. int16 GetPort() { return port; }
  45. void SetPort(int16 in_port) { port = in_port; }
  46. eServerMode GetLoginMode() { return LoginMode; }
  47. bool ReadLoginConfig();
  48. char* GetMasterAddress() { return masteraddress; }
  49. int16 GetUplinkPort() { if (uplinkport != 0) return uplinkport; else return port; }
  50. char* GetUplinkAccount() { return uplinkaccount; }
  51. char* GetUplinkPassword() { return uplinkpassword; }
  52. protected:
  53. friend class LWorld;
  54. bool Uplink_WrongVersion;
  55. private:
  56. int16 port;
  57. int listening_socket;
  58. char masteraddress[300];
  59. int16 uplinkport;
  60. char uplinkaccount[300];
  61. char uplinkpassword[300];
  62. eServerMode LoginMode;
  63. };