using System.Net.Sockets;
private readonly TcpClient _tcpClient;
private readonly object _readLocker = new object ();
private Stream _networkStream;
public TcpConn(string hostname, int port)
_tcpClient = new TcpClient();
_tcpClient.Connect(hostname, port);
_networkStream = _tcpClient.GetStream();
public int Read(byte[] b)
int byteLength = b.Length;
int total = _networkStream.Read(b, 0, byteLength);
if (total == byteLength || total == 0)
while (total < byteLength)
int n = _networkStream.Read(b, total, byteLength - total);