My understanding now is that after a certain number of messages going back
and forth, the server socket is overwhelmed and spews out the misleading
error message. This makes sense expect I'd prefer to have a error message
that is not misleading. But, if you goal is to provide a high
speed/throughput interface, how do you avoid such a problem?
As suggestions would be appreciated.
Grant
"Grant Richard" <dgrichard100@hotmail.com> wrote in message
news:OcleYx0lDHA.1408@TK2MSFTNGP11.phx.gbl...[color=blue]
> Yes and no. It did solve the initial problem. The changed loop looks[/color]
like.[color=blue]
>
> ....
>
> while( notDone )
> {
> try
>
> {
> Socket s = server.AcceptSocket();
> NetworkStream stream = new NetworkStream( s );
> string response = this.ReadMessage(stream, this.DisplayItServer);
> this.WriteMessage(response+" ***** GOT IT! ***** ", stream ,
> this.DisplayItServer);
> if( this.DisplayItServer )
> Console.Out.WriteLine("SERVER: response = " + response);
> s.Close();
> } ...
>
> That worked fine but at around 28000 interactions, the same message[/color]
cropped[color=blue]
> up.
>
> Number is 28000 10/20/2003 8:39:42 AM
> Number is 28200 10/20/2003 8:39:43 AM
> Number is 28400 10/20/2003 8:39:43 AM
> Number is 28600 10/20/2003 8:39:44 AM
> CLIENT:Exception->System.Net.Sockets.SocketException: Only one usage of[/color]
each[color=blue]
> soc
> ket address (protocol/network address/port) is normally permitted
> at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
> at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
> at NetStreamTest.TCPCommunication.GoClient(String message) in
> c:\temp\vs.net\
> netstreamtest\netstreamtest.cs:line 145
> Main:Exception at i =28613: System.Net.Sockets.SocketException: Only one
> usage o
> f each socket address (protocol/network address/port) is normally[/color]
permitted[color=blue]
> at NetStreamTest.TCPCommunication.GoClient(String message) in
> c:\temp\vs.net\
> netstreamtest\netstreamtest.cs:line 159
> at NetStreamTest.NetStreamTestMain.Main(String[] args) in
> c:\temp\vs.net\nets
> treamtest\netstreamtest.cs:line 69
>
> "Felix Wang" <v-felwa@online.microsoft.com> wrote in message
> news:NRwUz4vlDHA.1928@cpmsftngxa06.phx.gbl...[color=green]
> > Hi Grant,
> >
> > I think the problem is that you have opened too many sockets on the[/color][/color]
server[color=blue][color=green]
> > side without closing them.
> >
> > On my machine, I can reach around 3900 before the exception pops up.[/color][/color]
After[color=blue][color=green]
> > adding one line, the program can run continuously:
> >
> > s.Close();
> >
> > I put this line in your GoServer() method to close the Socket s. You may
> > also close the NetworkStream by calling stream.Close(), and call
> > s.ShutDown() method first to ensure all data is sent or received.
> >
> > I hope this helps.
> >
> > Regards,
> >
> > Felix Wang
> > Microsoft Online Partner Support
> > Get Secure! -
www.microsoft.com/security
> > This posting is provided "as is" with no warranties and confers no[/color][/color]
rights.[color=blue][color=green]
> >[/color]
>
>[/color]