Re: multithreaded tcp/ip monitoring application
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam>
- Date: Thu, 12 Jul 2007 10:50:41 -0600
TCP doesn't do any sort of blocking on it's packets. Since you know your
line length, you need to add each TCP packet to a master buffer as it
arrives and then take your data chunks off that buffer
Here's pseudo code -
int count = recv(socket, out buffer)
if count == 0 then the socket is gone.
msg += buffer.ToString()
while msg.Length > 61
string chunk = msg.Substr(0, 60)
msg = msg.Substr(61, msg.Length-61)
process(chunk)
loop
Although this error occurs mainly on fast connections, I have seen it occur
over dialup connections as well.
Mike.
"Punit Kaur" <PunitKaur@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8988E5B8-3D56-4044-86BC-12D94164F0F3@xxxxxxxxxxxxxxxx
Hi,
Thanks a lot foryour help. I can get the application working as of now.
But I still feel, it might not work in certain cases because I have made
superflous assumptions and I am not sure how to handle certain error
checks/cases. For example, I have written the client code in C# following
your suggestions. My server side code is in VC++. Since I am monitoring
the
status of an application, I added the server side code to the application
that is being monitored. That application sends data about its current
status( its doing some stuff and it sends information about that to the
client). I had a monitor thread running on the server side that
continously
sends updated application statistics to the monitoring application.
Now the problem is... the sending of the data is so fast that the
receiving
side is not able to keep up with it. From the server side I am sending
data
in a comma separated fashion. And each data packet I send has constant
length
61 bytes. If If do not add any delay in send, the receive at the client
side
receives 2-3 data packets and then is not able to parse the received data
properly.
So I added a delay of 5 sec on server side. So that the client has enough
time to process each packet it receives. But I am sure this might not work
always. I need some suggestions on how to synchronize the server and
client.
Should I send some acknowledgement back from the client everytime I
receive a
packet. I am new to c# as well as network programming.
And I need someone to help me with the design. Once I build my first app,
I
am sure I will do good in subsequent apps.
Pete, please give me some more pointers .
I have seen some chat applications in C#.. but they do not have everything
I
need.
Thanks a lot!
.
- References:
- Re: multithreaded tcp/ip monitoring application
- From: Peter Duniho
- Re: multithreaded tcp/ip monitoring application
- From: Punit Kaur
- Re: multithreaded tcp/ip monitoring application
- From: Punit Kaur
- Re: multithreaded tcp/ip monitoring application
- From: Peter Duniho
- Re: multithreaded tcp/ip monitoring application
- Prev by Date: Could not start application from Network,...
- Next by Date: Re: Could not start application from Network,...
- Previous by thread: Re: multithreaded tcp/ip monitoring application
- Next by thread: Re: multithreaded tcp/ip monitoring application
- Index(es):
Relevant Pages
|