public NetServer(IKeyExchange exchange, short port, OnMessageRecieved callback, OnClientConnectStateChanged onConn, int bufSize = 16384)
        {
            this.callback = callback;
            this.onConn   = onConn;
            this.bufSize  = bufSize;
            this.exchange = exchange;
            this.port     = port;

            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());

            this.ipAddress = ipHostInfo.GetIPV4();
            if (ipAddress == null)
            {
                ipAddress = IPAddress.Parse("127.0.0.1"); // If there was no IPv4 result in dns lookup, use loopback address
            }
        }
Exemple #2
0
        public NetServer(RSA crypto, short port, OnMessageRecieved callback, OnClientConnect onConn, int bufSize = 16384)
        {
            this.callback  = callback;
            this.onConn    = onConn;
            this.bufSize   = bufSize;
            this.crypto    = crypto;
            this.port      = port;
            this.ser_cache = crypto.Serialize(); // Keep this here so we don't wastefully re-serialize every time we get a new client

            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());

            this.ipAddress = ipHostInfo.GetIPV4();
            if (ipAddress == null)
            {
                ipAddress = IPAddress.Parse("127.0.0.1"); // If there was no IPv4 result in dns lookup, use loopback address
            }
        }