示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected bool pollRecv(pspsharp.HLE.TPointer data, pspsharp.HLE.TPointer32 dataLengthAddr, pspsharp.HLE.kernel.types.SceKernelThreadInfo thread) throws java.io.IOException
        protected internal virtual bool pollRecv(TPointer data, TPointer32 dataLengthAddr, SceKernelThreadInfo thread)
        {
            int  Length    = dataLengthAddr.getValue();
            bool completed = false;

            if (Length > 0)
            {
                if (RcvdData <= 0 || receivedMessage != null)
                {
                    update();
                }

                if (RcvdData > 0)
                {
                    if (Length > RcvdData)
                    {
                        Length = RcvdData;
                    }
                    // Copy the data already received
                    dataLengthAddr.setValue(Length);
                    Memory mem = Memory.Instance;
                    mem.memcpy(data.Address, buffer.addr, Length);
                    if (RcvdData > Length)
                    {
                        // Shift the remaining buffer data to the beginning of the buffer
                        mem.memmove(buffer.addr, buffer.addr + Length, RcvdData - Length);
                    }
                    rcvdData -= Length;

                    //if (log.DebugEnabled)
                    {
                        Console.WriteLine(string.Format("Returned received data: {0:D} bytes", Length));
                        if (log.TraceEnabled)
                        {
                            log.trace(string.Format("Returned data: {0}", Utilities.getMemoryDump(data.Address, Length)));
                        }
                    }
                    setReturnValue(thread, 0);
                    completed = true;
                }
            }

            return(completed);
        }
示例#2
0
        public virtual int send(int data, TPointer32 dataSizeAddr, int timeout, int nonblock)
        {
            int result = 0;

            try
            {
                AdhocMessage adhocMessage = networkAdapter.createAdhocPtpMessage(data, dataSizeAddr.getValue());
                send(adhocMessage);
            }
            catch (IOException e)
            {
                result = SceKernelErrors.ERROR_NET_ADHOC_DISCONNECTED;
                Console.WriteLine("send returning ERROR_NET_ADHOC_DISCONNECTED", e);
            }

            return(result);
        }