Home Forums Support Server to Clients or One to Many

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2419
    Anonymous
    Inactive

    Hi!
    I like your library, but have a problem with it. I would ask you to help me.
    I’m developing very nonstandard application. There is one Server and many Clients (I have ~300). I want to send a message from Server to all Clients. The main idea is to close working program on all Client PCs.

    For example i have a button in my program “Close my program on all my Clients PCs”. Also I know all Client IPs.

    Thanks, and sorry for my English 🙂

    • This topic was modified 10 years, 9 months ago by .
    • This topic was modified 10 years, 9 months ago by .
    #2421
    Anonymous
    Inactive

    I’m not sure what your question is. I can however say that it would be very easy to achieve what you are trying to do with NetworkComms.Net.

    Regards,
    Marc

    #2423
    Anonymous
    Inactive

    Yes, I want to use NetworkComms.Net in my project.
    The question is: how can I send a message to all clients?
    I know their IPs.
    Thanks.

    • This reply was modified 10 years, 9 months ago by .
    #2425
    Anonymous
    Inactive

    You can either use a UDP broadcast which is the most efficient for a large number of clients:

    //Broadcast a shutdown state object to all local network clients
    ShutdownState state = new ShutdownState();
    NetworkCommsDotNet.Connections.UDP.UDPConnection.SendObject("ClientShutdown", state, new IPEndPoint(IPAddress.Broadcast, 10000));

    or using TCP:

    List<IPAddress> clientAddresses = new List<IPAddress>() { /* All IPs go here */ };
    ShutdownState state = new ShutdownState();
    
    //Connect to each client and send the shutdown packet
    foreach (IPAddress address in clientAddresses)
    {
        try
        {
            ConnectionInfo clientInfo = new ConnectionInfo(new IPEndPoint(address, 10000));
            NetworkCommsDotNet.Connections.TCP.TCPConnection.GetConnection(clientInfo).SendObject("ClientShutdown", state);
        }
        catch (CommsException)
        {
            Console.WriteLine("Failed to send shutdown to {0}", address.ToString());
        }
    }

    Regards,
    Marc

    #2426
    Anonymous
    Inactive

    Thanks for reply. I will try it in my project. Thanks a lot again. If any questions, I will post.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.