Example #1
0
        public void Listen(object objs)
        {
            InputSocket iss = objs as InputSocket;

            iss.inputSocket.Listen(0);
            foreignSocket = iss.inputSocket.Accept();
            int i = 1;

            while (true)
            {
                byte[] objectSize = new byte[4];
                foreignSocket.Receive(objectSize, 0, 4, SocketFlags.None);
                int messageSize = BitConverter.ToInt32(objectSize, 0);
                Console.WriteLine(messageSize);

                byte[] bytes    = new byte[messageSize];
                int    readByte = foreignSocket.Receive(bytes);

                Thread t;
                t = new Thread(() =>
                {
                    messageIn = GetDeserializedMessage(bytes);
                    Console.WriteLine(i + ": " + messageIn.s + " | " + messageIn.output_port + " | " + messageIn.timestamp);
                    SendSingleMessage(messageIn);
                    i++;
                }
                               );
                t.Start();
            }
        }
Example #2
0
 public void Listen2()
 {
     InputSocket[] iss = InitializeArray <InputSocket>(ports.Length);
     for (int i = 0; i < ports.Length; i++)
     {
         iss[i] = new InputSocket(ports[i]);
         Thread t = new Thread(Listen);
         t.Start(iss[i]);
     }
 }
Example #3
0
        public void Listen(object objs)
        {
            int i = 1;

            while (true)
            {
                InputSocket iss = objs as InputSocket;
                iss.inputSocket.Listen(0);
                foreignSocket = iss.inputSocket.Accept();
                byte[] bytes    = new byte[foreignSocket.SendBufferSize];
                int    readByte = foreignSocket.Receive(bytes);

                Thread t;
                t = new Thread(() =>
                {
                    messageIn = GetDeserializedMessage(bytes);
                    Console.WriteLine(i + ": " + messageIn.s + " | " + messageIn.output_port + " | " + messageIn.timestamp);
                    SendSingleMessage(messageIn);
                    i++;
                }
                               );
                t.Start();
            }
        }