Ejemplo n.º 1
0
        // For Ptp sockets, data in read as a byte stream. Data is not organized in packets.
        // Read as much data as the provided buffer can contain.
        public virtual int recv(TPointer data, TPointer32 dataLengthAddr, int timeout, int nonblock)
        {
            int result = 0;

            try
            {
                SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread;
                if (pollRecv(data, dataLengthAddr, thread))
                {
                    // Recv completed immediately
                    result = thread.cpuContext._v0;
                }
                else if (nonblock != 0)
                {
                    // Recv cannot be completed in non-blocking mode
                    result = SceKernelErrors.ERROR_NET_ADHOC_NO_DATA_AVAILABLE;
                }
                else
                {
                    // Block current thread
                    BlockedPdpAction blockedPdpAction = new BlockedPtpRecv(this, data, dataLengthAddr, timeout);
                    blockedPdpAction.blockCurrentThread();
                }
            }
            catch (IOException e)
            {
                result = SceKernelErrors.ERROR_NET_ADHOC_DISCONNECTED;
                Console.WriteLine("recv", e);
            }

            return(result);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 protected internal BlockedPtpRecv(PtpObject ptpObject, TPointer data, TPointer32 dataLengthAddr, int timeout) : base(ptpObject, timeout)
 {
     this.data           = data;
     this.dataLengthAddr = dataLengthAddr;
 }