Re: TCP listener
- From: "Markgoldin" <markgoldin_2000@xxxxxxxxx>
- Date: Fri, 18 Jul 2008 14:54:59 -0500
Here is my modified code:
while (monitorPort)
{
byteReadStream = new byte[tcpc.Available]; //allocate space for data
tcpc.GetStream().Read(byteReadStream, 0, tcpc.Available);
//read data into byte array
if (byteReadStream != null)
{
monitorPort = false;
}
System.Console.WriteLine("In the loop");
}
The change is
System.Console.WriteLine("In the loop");
When I send data to the listener I see "In the loop" two times, after
disconnecting in starts writing "In the loop" without stoping.
Any idea why it gets into the loop after disconnecting?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin@xxxxxxxxx> wrote in
message
news:dda5cb03-7581-492c-91aa-17813cea7eb3@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 18, 3:04 pm, "Markgoldin" <markgoldin_2...@xxxxxxxxx> wrote:
Like I said, I am not a c# programmer, but I need a little c# code for my
application.
I understand your commens though and will look into it.
But for now it's fine with one connection only however the following
TcpClient tcpc = DataAdapterLauncher.tcpl.AcceptTcpClient(); //accept
connectionHow do you return to the above line?
If you never do, you can only create one connection
is the reason of CPU going 100% after a client closes connection?
no, of course not, that line is executed AT the connection time, then
you enter in the while loop
do this, copy your code in a win or console project and see where it
gets stuck
.
- References:
- TCP listener
- From: Markgoldin
- Re: TCP listener
- From: Ignacio Machin ( .NET/ C# MVP )
- Re: TCP listener
- From: Markgoldin
- Re: TCP listener
- From: Ignacio Machin ( .NET/ C# MVP )
- TCP listener
- Prev by Date: Re: code diff tool
- Next by Date: Re: code diff tool
- Previous by thread: Re: TCP listener
- Next by thread: Re: TCP listener
- Index(es):
Relevant Pages
|