可以先PING一下,能PING得通再connect

解决方案 »

  1.   

    但是ping得通的不一定开了Ftp服务,到时候还是等半天。再说很多机器有防火墙,根本不让ping啊。
      

  2.   

    使用asynchronous connection allDone.Reset();
    s.BeginConnect(lep, new AsyncCallback(Async_Send_Receive.Connect_Callback), s);
    allDone.WaitOne(2000, false);这会把connection timeout设为2秒当然,你要写一个Connect_Callback delegate