Ejemplo n.º 1
0
        internal void SocketClientTest()
        {
            AppClient <FileProtocol> appClient = new AppClient <FileProtocol>();

            appClient.Connected += (sender, args) =>
            {
                Console.WriteLine(args);
                FileProtocol protocol = new FileProtocol();
                protocol.FileName = "test.file";
                FileStream fileStream = new FileStream("c:\\aa.file", FileMode.Open);
                byte[]     buffer     = new byte[1024];
                int        offset     = 0;
                do
                {
                    offset          = fileStream.Read(buffer, offset, buffer.Length);
                    protocol.Offset = offset;
                    protocol.Data   = buffer;
                    appClient.Send(protocol);
                } while (offset != 0);
            };
            appClient.Received     += (sender, args) => { Console.WriteLine(args); };
            appClient.Disconnected += (sender, args) => { Console.WriteLine(args); };
            ////appClient.Connect("192.168.0.36", 2001);
            appClient.Connect("127.0.0.1", 8099);
        }