System.Net.Sockets.SocketException: 协议家族尚未配置到系统中或没有它的存在迹象。
//检查当前模式
private NetworkStream Mode(bool PassiveMode,ref TcpClient client,ref Socket clientSocket,string strIP,int Port)
{
Thread oThread=Thread.CurrentThread;
NetworkStream nw=null;
lock (oThread)
{
if(PassiveMode)
{
//MessageBox.Show("passive");
//套接字处于打开状态
if (clientSocket!=null)
{
nw=new NetworkStream(clientSocket,FileAccess.ReadWrite); //运行到这里
}
}
else
{
MessageBox.Show("else");
//客户端连接
client=new TcpClient(strIP,Port); ///运行到这里 line 802
nw=client.GetStream();
}
}
return nw;
}
//运行到上面的位置的时候就出现以下错误:
System.Net.Sockets.SocketException: 协议家族尚未配置到系统中或没有它的存在迹象。
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPAddress address, Int32 port)
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at FTP.FTP.Mode(Boolean PassiveMode, TcpClient& client, Socket& clientSocket, String strIP, Int32 Port) in c:\documents and settings\administrator.zc\my documents\visual studio projects\ftp\ftp.cs:line 802
at FTP.FTP.FTPClientThread() in c:\documents and settings\administrator.zc\my documents\visual studio projects\ftp\ftp.cs:line 263
///line 263是引用mode的位置行~~
哎,头大了~~是什么原因呢?