private void AcceptCallback(IAsyncResult ar) { var client = _listener.EndAcceptTcpClient(ar); var newSocket = new ClientSocket(); newSocket.Disconnected += NewSocket_Disconnected; newSocket.Accept(client); WriteToBox("Accepted Client!!!"); AcceptFunction(); }
/// <summary> /// /// </summary> /// <param name="host"></param> /// <param name="port"></param> public void Connect(string host = "localhost", int port = 30001) { try { client = new ClientSocket(); client.DataReceived += Client_DataReceived; client.Disconnected += Client_Disconnected; client.Connected += Client_Connected; client.Accept(new TcpClient(host, port)); } catch (Exception ex) { } }
public Client(TcpClient sock) { DataAvailable = false; // -- Instantiate our needed items _receiveBuffer = new ByteBuffer(); SendBuffer = new ByteBuffer(); _socket = new ClientSocket(); BlockChanges = new ConcurrentQueue <SetBlockServer>(); ChatBuffer = ""; PopulatePackets(); // -- Register events _socket.DataReceived += SocketOnDataReceived; _socket.Disconnected += SocketOnDisconnected; SendBuffer.DataAdded += SendBufferOnDataAdded; _canReceive = true; _disconnectOnSend = false; Ip = ((IPEndPoint)(sock.Client.RemoteEndPoint)).Address.ToString(); // -- Assign the TcpClient to our ClientSocket, to make it start handling events. _socket.Accept(sock); _lastActive = DateTime.UtcNow; // -- Setup the timeout task Interval = TimeSpan.FromSeconds(1); _taskId = Ip + new Random().Next(2035, 193876957); _taskId = TaskScheduler.RegisterTask(_taskId, this); Kick("You suck lol"); //Server.RegisterClient(this); //if (Player.Database.IsIpBanned(Ip)) { // Kick(BannedMessage); //} }
public void AcceptClient(TcpClient incomingClient) { _baseSocket.Accept(incomingClient); }
public Socket ListenPort() { var connection = ClientSocket.Accept(); return(connection); }