Example #1
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            Byte[] fileBytes;
            string ip       = ipText.Text;
            int    port     = 30000;
            string filename = File.Text;

            Client client = new Client();
            var    cl     = client.Connect(ip, port);
            var    fe     = new FileExchange();

            fileBytes = fe.LoadFile(filename);
            client.Send(cl, fileBytes);
        }
        private void ReceiveButton_Click(object sender, RoutedEventArgs e)
        {
            string path = pathText.Text;

            server = new Server();
            var fe = new FileExchange();

            server.OnConnectEvent += (tcpClient) =>
            {
                Console.WriteLine(tcpClient.Client.RemoteEndPoint);
            };
            server.receiveCallBack += (bytes) =>
            {
                fe.WriteFile(path, bytes);
            };
            server.Accept();
        }