public void Connect()
{
if (server == null)
throw new Exception("No server has been set.");
if (user == null)
throw new Exception("No username has been set.");
if (main_sock != null)
if (main_sock.Connected)
return;
main_sock = new Socket(
AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp
);
SetSocketTimeout(main_sock);
try
{
main_sock.Connect(server, port);
//main_sock_LineReader = new StreamReader(new NetworkStream(main_sock));
main_sock_LineReader = new NetworkStream(main_sock);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
ReadResponse();
if (response != 220)
Fail();
SendCommand("USER " + user);
ReadResponse();
switch (response)
{
case 331:
if (pass == null)
{
Disconnect();
throw new Exception("No password has been set.");
}
SendCommand("PASS " + pass);
ReadResponse();
if (response != 230)
Fail();
break;
case 230:
break;
}
return;
}
/// <summary>