Page 141 - CSharp/C#
P. 141

tpp.TryToConnect();
             }

             private void SendClick(object sender, EventArgs e)
             {
                 Client.SendString("Test data from client");
             }


        The client class I used in this example


             public static void SetClient(Socket socket)
             {
                 Id = 1;
                 Socket = socket;
                 Receive = new ReceivePacket(socket, Id);
                 SendPacket = new SendPacket(socket);
             }


        Notice


        The Receive Class from the server is the same as the receive class from the client.


              Conclusion

        You now have a server and a client. You can work this basic example out. For example make it
        that the server also can receive files or other tings. Or send a message to the client. In the server
        you got a list of client so when you receive something you will know from with client it came from.

        Final result:














































        https://riptutorial.com/                                                                               87
   136   137   138   139   140   141   142   143   144   145   146