用socket进行连接的时候出现错误:通常每个套接字地址 协议 网络地址 端口 只允许使用一次。
运行环境win2000server,请高手解答,比较及,分还可以加。
谢谢程序代码如下:static void Main(string[] args)
{
AppMain app = new AppMain();
// connStr = app.GetConnStr();
// Welcome and Start listening
app.log.WriteLog("*** ESP Server Started " + DateTime.Now.ToString( "G" ) + "***" , EventLogType.Information);
int nPortListen = app.GetPort();//7893;
            app.GetBufferSize();
Socket listener = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
listener.Bind( new IPEndPoint( IPAddress.Any ,nPortListen ) );
listener.Listen( 500 );
app.log.WriteLog("Listening on : " + nPortListen , EventLogType.Information);
// app.StartMt();

listener.BeginAccept( new AsyncCallback( app.OnConnectRequest ), listener );
Console.WriteLine ("Press Enter to exit" );
Console.ReadLine();
app.log.WriteLog("Server is Closed",EventLogType.Information);
app.mas.Close();//关闭mas
// Clean up before we go home
try
{
app.workflag = false;
listener.Close();

app.rotation1.Abort();
int tol = app.m_aryClients.Count;
int i = 0;
while(i < tol )
{
SocketChatClient client = (SocketChatClient)app.m_aryClients[i];
client.Sock.Shutdown(SocketShutdown.Send);
client.SendIsVal = false;
i++;
app.m_aryClients.Remove(client);
}
   }
catch(Exception e)
{
app.log.WriteLog(e,"关闭异常"); }
// Console.ReadLine();
}