Re: multithreaded tcp/ip monitoring application



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!


.



Relevant Pages

  • [REVS] Backdoor Spotcom Analysis
    ... Spotcom is a backdoor client application that allows a hacker to control ... The server IP address is hard-coded in ... msrsvp.exe accepts a couple of command line arguments. ... the packet payload. ...
    (Securiteam)
  • Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Socket weirdness
    ... client) before you will notice a shutdown receive at server. ... Then eventually a packet comes from the peer, and that will contain data, so the server responds RST: ... way back across the network. ...
    (microsoft.public.dotnet.framework)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)