示例#1
0
        public void Run()
        {
            m_socket = new MicroSocket();

            //Console.Write("-");

            s_connectingSockets++;

            IPAddress baal     = IPAddress.Parse("127.0.0.1");
            IPAddress torturer = IPAddress.Parse("192.168.1.1");

            if (m_socket.Connect(baal, 12345) == false)
            {
                Console.WriteLine("Connection failed");
                return;
            }

            s_connectingSockets--;
            s_connectedSockets++;

            /*
             * while (s_connectedSockets < 500)
             *      MicroThread.CurrentThread.Sleep(1000);
             */

            //Console.Write(".");

            long sentBlocks = 0;

            byte[] buf = new byte[m_blockSize];
            while (true)
            {
                m_socket.Send(buf, buf.Length);

                sentBlocks++;
                s_totalBlocksSent++;

                if (sentBlocks >= m_blocksToSend)
                {
                    break;
                }
            }

            //Console.Write("x");
            s_connectedSockets--;

            m_socket.Shutdown();
            m_socket.Close();
        }
示例#2
0
        public void SocketRun()
        {
            byte[] buf = new byte[s_bufferSize];
            while (true)
            {
                int len = m_socket.Receive(buf);

                if (len == 0)
                {
                    break;
                }

                s_totalBytesReceived += len;
            }

            //Console.Write("x");

            s_connectedSockets--;

            m_socket.Shutdown();
            m_socket.Close();
        }