internal Socks5Client(TcpClient client) { InternalClient = client; _connectedCompletion = new TaskCompletionSource<bool>(); _connectedCompletion.SetResult(true); }
private static void StartSending() { _client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1111)); WriteLine("Enter d to disconnect, q to abort"); while (true) { Write("Send: "); var data = ReadLine(); if (string.IsNullOrEmpty(data)) continue; if (data.Length == 1) { switch (data[0]) { case 'd': _client.Disconnect(); return; case 'q': _client = null; return; } } var bytes = Encoding.UTF8.GetBytes(data); _client.SendAll(bytes); } }
public void BeginAccept() { _socket.BeginAccept((result) => { var clientSocket = _socket.EndAccept(result); var client = new TcpClient(clientSocket); ClientConnected?.Invoke(this, new ClientEventArgs(client)); }, null); }
public Socks5Client(EndPoint socksServer) { InternalClient = new TcpClient(); _connectedCompletion = new TaskCompletionSource<bool>(); Task.Run(async () => { var result = await ConnectWithSocksServer(socksServer); _connectedCompletion.SetResult(result); }); }
static void Main(string[] args) { _client = new TcpClient(); StartSending(); }
internal Task<bool> ConnectWith(EndPoint endPoint) { _endPointClient = new TcpClient(); return _endPointClient.ConnectAsync(endPoint); }
public TransferEventArgs(TcpClient client, byte[] bytes, int count) { Client = client; Bytes = bytes; Count = count; }
public ClientEventArgs(TcpClient client) { Client = client; }