Exemple #1
0
        private void Send_Click(object sender, EventArgs e)
        {
            try
            {
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                byte[] msg = new byte[262200];
                msg = enc.GetBytes(MessageToSend.Text);
                sck.Send(msg);

                showNewMessage(MessageToSend.Text, false);
                MessageToSend.Clear();
                MessageToSend.Focus();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not send message:");
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #2
0
        private void start(int port, String otherAddress, int otherPort)
        {
            try
            {
                epLocal = new IPEndPoint(IPAddress.Parse(GetLocalIPAddress()), port);
                sck.Bind(epLocal);

                epRemote = new IPEndPoint(IPAddress.Parse(otherAddress), otherPort);
                sck.Connect(epRemote);

                byte[] buffer = new byte[262200];
                sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer);

                MessageToSend.Focus();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not start:");
                Console.WriteLine(ex.ToString());
            }
        }
 private void ClearLog(object sender, RoutedEventArgs e)
 {
     MessageLog.Document.Blocks.Clear();
     MessageToSend.Focus();
 }