Solved

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

Posted on 2009-04-02
4
694 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

734 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