public void Connect()
{
if (host==null)
throw new Exception("no host");
IPHostEntry hostEntry = Dns.GetHostEntry(host);
if (hostEntry==null)
throw new Exception("can't get ip");
// construct the endpoint
IPEndPoint endPoint=new IPEndPoint(hostEntry.AddressList[0],port);
if (endPoint==null)
throw new Exception("can't get endpoint");
// initialize socket
socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
// set the socket timeout
//socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, sendTimeout);
//socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, receiveTimeout);
socket.Connect(endPoint);
ReceiveLine();
}