none
Redirect TCP data from a Server to a single Client RRS feed

  • Question

  • Friends:

    I have installed NuGet's SimpleTCP package to implement a Server which works. After connecting 3 clients or more (the clients connect them using the Hercules software) I want to send data to only one of them ("ClientX") the data that the others send to the Server but I do not know how to redirect the data to the "ClientX". I have Clients with different IPs in the same network as the Server and others in an external public network.

    private void Form1_Load(object sender, EventArgs e)
            {
                Server = new SimpleTcpServer();
                Server.Delimiter = 0x13;
                Server.StringEncoder = Encoding.UTF8;
                Server.DataReceived += Data_Rx;
            }
     
            private void Data_Rx(object sender, SimpleTCP.Message e)
            {
                // get IP client
                IpClient = ((IPEndPoint)(e.TcpClient.Client.RemoteEndPoint)).Address.ToString();
                Datar = e.MessageString; // Read message
               e.ReplyLine(string.Format("ok: {0}", Datar)); // I send an answer, this is where I should send it to
                 // "ClientX" but this response is addressed to the client that currently sent a data
           }

    Any idea?

    Thank you.

    Wednesday, May 29, 2019 6:31 PM

All replies

  • Hi Javiervs15,

    Thank you for posting here.

    Since SimpleTCP is a third-party product, I suggest that you could post in the following forum.

    https://csharpforums.net/forums/third-party-products.89/

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Note:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 30, 2019 5:17 AM
  • ok thanks.
    Thursday, May 30, 2019 7:59 PM
  • The ClientConnected callback gets called when a new client connects.  You can keep your own list of the current connections.  How will you choose the right one?

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, May 31, 2019 6:36 PM
  • All clients connecting to the server send a different header with their name, the "abc" client is the one to whom I should redirect the data of the other clients.
    Sunday, June 2, 2019 10:14 AM