Exemplo n.º 1
0
 protected override Socket CreateAcceptSocket(IPEndPoint endpoint)
 {
     var socket = new PgmSocket();
     socket.Bind(endpoint);
     socket.SetPgmOption(PgmConstants.RM_HIGH_SPEED_INTRANET_OPT, PgmSocket.ConvertStructToBytes(true));
     socket.EnableGigabit();
     socket.Listen(5);
     return socket;
 }
Exemplo n.º 2
0
        public void should_create_socket()
        {
            var ipEndPoint = new IPEndPoint(IPAddress.Parse("224.0.0.24"), 2000);

            _acceptSocket = new PgmSocket();
            _acceptSocket.Bind(ipEndPoint);
            _acceptSocket.EnableGigabit();
            _acceptSocket.Listen(5);
            var acceptEventArgs = new SocketAsyncEventArgs();
            acceptEventArgs.Completed += OnAccept;

            _acceptSocket.AcceptAsync(acceptEventArgs);

            var sendingSocket = new PgmSocket();
            sendingSocket.SendBufferSize = 1024 * 1024;
            sendingSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
            SetSendWindow(sendingSocket);
            sendingSocket.EnableGigabit();
            sendingSocket.Connect(ipEndPoint);

            var sendingSocket2 = new PgmSocket();
            sendingSocket2.SendBufferSize = 1024 * 1024;
            sendingSocket2.Bind(new IPEndPoint(IPAddress.Any, 0));
            SetSendWindow(sendingSocket2);
            sendingSocket2.EnableGigabit();
            sendingSocket2.Connect(ipEndPoint);

            var buffer = Encoding.ASCII.GetBytes("toto");
            var buffer2 = Encoding.ASCII.GetBytes("toto2");
            var buffer3 = Encoding.ASCII.GetBytes("toto3");
             //       sendingSocket.Send(new byte[3000], 0, 3000, SocketFlags.None);
               //     sendingSocket2.Send(buffer2, 0, buffer2.Length, SocketFlags.None);
               //         sendingSocket.Send(buffer, 0, buffer.Length, SocketFlags.None);
             //       sendingSocket.Send(buffer2, 0, buffer2.Length, SocketFlags.None);

            Thread.Sleep(100);
            var bigBuffer = new byte[200000];
            var sent = sendingSocket.Send(bigBuffer, 0, bigBuffer.Length, SocketFlags.None);
            sendingSocket.Send(buffer3, 0, buffer3.Length, SocketFlags.None);
            //    sendingSocket.Send(buffer3, 0, buffer3.Length, SocketFlags.None);

            Thread.Sleep(25000);
        }