Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-04-02
4
Medium Priority
?
702 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 1500 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 1500 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

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

670 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