Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
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…
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…
Suggested Courses

926 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