Solved

Searching tcp client/socket class robust and reliable in .NET 2.0

Posted on 2009-04-02
4
683 Views
Last Modified: 2012-05-06
Hi experts,

i have my own  class of tcp and it works but sometimes, i have memory leak or a command that i have to send that is not sent ;(

that's why i'm asking if somebody have a wrapper tcp/socket client that can run 24/7 and when i send command, i have to be sure that the command is really sent.

regards
0
Comment
Question by:Dnx_7
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24048235
What's wrong with the System.Net.Sockets.TcpClient? The nature of TCP is that if a packet is mangled or received out of order, it'll be retransmitted. For every tcp packet sent, it requires an Acknowledgement packet to be received:
eg:

client -> server syn
server -> client syn, ack
client -> server ack
server -> client psh, ack
client -> server ack
server -> client fin, ack
client -> server fin, ack
server -> client ack

So the TcpClient will throw an exception if a send fails. If no exception is thrown you can be sure that the data has been sent successfuly
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 24048312
i don't know because i'm still too new on network programmation but i use

myTCPClient.getstream.write(...)

i don't have any error but sometimes there is micro network disconnection or something else
but the order is not sent correctly :(

regards
0
 
LVL 15

Assisted Solution

by:oobayly
oobayly earned 500 total points
ID: 24049216
Hmm, that's a little strange as if there's a problem transport, the packet should be retried a bit like this:
  1. Resend after 3 seconds
  2. Resend after 6 seconds
  3. Resend after 12 seconds
  4. ...
  5. Timeout
and if it fails, an IOException should be throw by NetworkStream.Write()

Obviously this is an intermittent problem which are a pain to diagnose. The only way I ever managed to diagnose problems like this was to run Wireshark capture all the data sent by my client-server application, when ever something unexpected happened (such as the client sending data, but the server not receiving) I would have to trawl through the capture data and try to figure out what actually happened on the wire.
It's probably the second best way to fry your brain (after taking LSD), but if you get adept at it you'll feel like Neo in The Matrix :-)
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 24183890
Thank you guys
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Exception in Log4Net 1 19
How to open a link from vb.net app 3 9
Add and format columns in vb6 7 22
Spacing between controls 4 16
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now