Пример #1
0
        void Sender()
        {
            while (!End)
            {
                try
                {
                    SuzukiMessage msg = SendQueue.Take();

                    Byte[] data = Encoding.ASCII.GetBytes(msg.Msg);

                    TcpClient client = new TcpClient(msg.Address, msg.Port);

                    NetworkStream stream = client.GetStream();
                    stream.Write(data, 0, data.Length);

                    stream.Close();
                    client.Close();
                }
                catch (SocketException e)
                {
                    LogMessage(this, e.ToString());
                }
                catch (InvalidOperationException)
                {
                    // SendQueue has ended.
                }
            }
        }
Пример #2
0
        public void Send(string content, UInt16 port, string address)
        {
            SuzukiMessage msg = new SuzukiMessage(content, port, address);

            SendQueue.Add(msg);
        }