private void accept() { serverThread = new Thread( () => { while (true) { if (connectionFinder != null) { try { Socket acceptedSocket = connectionFinder.Accept(); IPAddress address = (acceptedSocket.RemoteEndPoint as IPEndPoint).Address; string id = IDMaker.getID(address); OnSocketCreated(id, acceptedSocket); //socket created for new client evetn fire } catch (Exception e) { Console.WriteLine(e); serverThread.Abort(); } } } }); serverThread.Start(); }
protected virtual void OnsocketConnected(IPEndPoint endPoint) { if (SocketConnected != null) { string idOfServer = IDMaker.getID(endPoint.Address); SocketConnected(this, new SocketAddedEventArgs() { id = idOfServer, socket = connectingSocket }); } }