Beispiel #1
0
        void RecvProcess()
        {
            while (true)
            {
                try
                {
                    RecvBuffer data = new RecvBuffer();

                    data.buffer = new byte[4];
                    data.size   = sizeof(int);
                    data.offset = 0;

                    int retval = Recv(data);
                    data.size   = BitConverter.ToInt32(data.buffer, 0);
                    data.buffer = new byte[data.size];

                    while (data.size > 0)
                    {
                        retval = Recv(data);
                        if (retval == 0)
                        {
                            break;
                        }

                        data.size   -= retval;
                        data.offset += retval;
                    }

                    data.size = data.offset;

                    lock (m_lock)
                        m_RecvBuffer.Enqueue(data);
                }
                catch
                {
                    //print("Recv Error");
                    continue;
                }
            }
        }
Beispiel #2
0
        void RecvProcess()
        {
            while (true)
            {
                RecvBuffer data = new RecvBuffer();
                try
                {
                    data.buffer = new byte[4];
                    data.size   = sizeof(int);
                    data.offset = 0;

                    int retval = Recv(data);
                    data.size   = BitConverter.ToInt32(data.buffer, 0);
                    data.buffer = new byte[data.size];

                    while (data.size > 0)
                    {
                        retval = Recv(data);
                        if (retval == 0)
                        {
                            break;
                        }

                        data.size   -= retval;
                        data.offset += retval;
                    }

                    data.size = data.offset;
                }
                catch (SocketException e)
                {
                    print("Socket Error : " + e.Message.ToString());
                    continue;
                }
                m_RecvBuffer.Enqueue(data);
            }
        }
Beispiel #3
0
 public int Recv(RecvBuffer ptr)
 {
     return(Net.Read(ptr.buffer, ptr.offset, ptr.size));
 }