Ejemplo n.º 1
0
        void CreateClient()
        {
            // Create the client
            var client = new SimplSocketClient();

            // Make the client connect automatically
            client.AutoConnect();

            // Wait until the connection is actually made
            client.WaitForConnection();

            // Create a byte array to send
            var messageToSend = new byte[1000];

            // Send it
            Console.WriteLine("Client will send message and wait for reply");
            var receivedMessage = client.SendReceive(messageToSend);

            if (receivedMessage == null)
            {
                Console.WriteLine("Client received no answer");
            }
            else
            {
                Console.WriteLine($"Client received answer of {receivedMessage.Length} bytes");

                // Return message to pool
                receivedMessage.Return();
            }
        }
Ejemplo n.º 2
0
        void CreateClient()
        {
            // Create the client
            var client = new SimplSocketClient();

            // Make the client connect automatically
            client.AutoConnect();

            // Wait until the connection is actually made
            client.WaitForConnection();

            // Create a byte array to send
            var arrayToSend1 = new byte[1000];

            // Send it
            client.Send(arrayToSend1);

            // Get a byte array from the memory pool
            var arrayToSend2 = PooledMessage.Rent(1000);

            client.Send(arrayToSend2);

            // We will not dispose the message directly, since it may still need to be send
            // Instead we use the ReturnAfterSend, which will return the message to the pool after sending
            arrayToSend2.ReturnAfterSend();
        }
Ejemplo n.º 3
0
 public void WaitForConnection()
 {
     _simplSocketClient.WaitForConnection();
 }