net.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. allowAccountCreation = true;
  37. }
  38. void UpdateWindowTitle(char* iNewTitle = 0);
  39. bool Init();
  40. void ListenNewClients();
  41. void HitKey(int keyhit);
  42. char address[1024];
  43. int32 numclients;
  44. int32 numservers;
  45. int16 GetPort() { return port; }
  46. void SetPort(int16 in_port) { port = in_port; }
  47. eServerMode GetLoginMode() { return LoginMode; }
  48. bool ReadLoginConfig();
  49. char* GetMasterAddress() { return masteraddress; }
  50. int16 GetUplinkPort() { if (uplinkport != 0) return uplinkport; else return port; }
  51. char* GetUplinkAccount() { return uplinkaccount; }
  52. char* GetUplinkPassword() { return uplinkpassword; }
  53. bool IsAllowingAccountCreation() { return allowAccountCreation; }
  54. protected:
  55. friend class LWorld;
  56. bool Uplink_WrongVersion;
  57. private:
  58. int16 port;
  59. int listening_socket;
  60. char masteraddress[300];
  61. int16 uplinkport;
  62. char uplinkaccount[300];
  63. char uplinkpassword[300];
  64. eServerMode LoginMode;
  65. bool allowAccountCreation;
  66. };