C# TcpClient/TcpListener / Full Duplex Communication / Sample

Markus Freitag 3,791 Reputation points
2023-02-01T17:23:47.48+00:00

Hello!

I have already asked. There must be a good example of Socket, TcpClient, TcpListener that does the following.

  • Duplex operation between client and server
  • Automatic reconnection
  • On 10 failed attempts, error message.
  • Read until the root element is received.
  • Read until the element root has been received, if necessary buffer it in a processing list and process it bit by bit

Send from Server to Client or the other way around.

<ROOT>
  <REQUESTS>
    <VARIANT name="TEST01022034">
      <PROGRAM name="87.1554.0_87.1554.0" />
    </VARIANT>
    <VARIANT name="TEST01022023">
      <PROGRAM name="99.884.0_M" />
      <PROGRAM name="99.884.0_MR" />
      <PROGRAM name="AAA_AAAAA" />
      <PROGRAM name="BBB_AAAAA" />
    </VARIANT>
  </REQUESTS>
</ROOT>

Send from Client to Server or the other way around.

<ROOT>
  <RESPONSE>
    <CURRENT name="TEST01022034">
      <PRODUCT name="Washing_machine_99.8854.0_99.8854.0" />
    </CURRENT>
   </RESPONSE>
</ROOT>

There are many small examples, 1000 variants. Is there a good working example for this use case? Thank you in advance for your help.

Windows Desktop App, WPF App or Windows Forms App. VS2017/2019

Developer technologies | .NET | Other
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-02-02T08:36:35.1433333+00:00

    Hi @Markus Freitag , Welcome to Q&A.

    Regarding Socket, TcpClient and TcpListener, I have written a winforms related example.

    Among them are about creating tcplistener and using tcpclient to connect.

    Please refer to this link and post an update if you have any questions.

    Best Regards, Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.