NS_IMETHODIMP nsBaseContentStream::ReadSegments(nsWriteSegmentFun fun, void *closure, PRUint32 count, PRUint32 *result) { *result = 0; if (mStatus == NS_BASE_STREAM_CLOSED) return NS_OK; // No data yet if (!IsClosed() && IsNonBlocking()) return NS_BASE_STREAM_WOULD_BLOCK; return mStatus; }
nglString nuiTCPServer::GetDesc() const { nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP); GetLocalHost(source); uint32 S = source.GetIP(); uint8* s = (uint8*)&S; nglString str; str.CFormat("%5d: %s - bound %d.%d.%d.%d:%d (%d clients) [ %s ]", GetSocket(), IsNonBlocking() ? "NoBlock" : "Block ", s[0], s[1], s[2], s[3], ntohs(source.GetPort()), mAcceptedCount, mName.GetChars()); return str; }
NS_IMETHODIMP nsFileUploadContentStream::AsyncWait(nsIInputStreamCallback *callback, uint32_t flags, uint32_t count, nsIEventTarget *target) { nsresult rv = nsBaseContentStream::AsyncWait(callback, flags, count, target); if (NS_FAILED(rv) || IsClosed()) return rv; if (IsNonBlocking()) { nsCOMPtr<nsIRunnable> callback = NS_NewRunnableMethod(this, &nsFileUploadContentStream::OnCopyComplete); mCopyEvent->Dispatch(callback, mSink, target); } return NS_OK; }
nglString nuiSocket::GetDesc() const { nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP); nuiNetworkHost dest(0, 0, nuiNetworkHost::eTCP); GetLocalHost(source); GetDistantHost(dest); uint32 S = source.GetIP(); uint32 D = dest.GetIP(); uint8* s = (uint8*)&S; uint8* d = (uint8*)&D; nglString str; str.CFormat("%5d: %s - from %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d [ %s ]", GetSocket(), IsNonBlocking() ? "NoBlock" : "Block ", s[0], s[1], s[2], s[3], ntohs(source.GetPort()), d[0], d[1], d[2], d[3], ntohs(dest.GetPort()), mName.GetChars()); return str; }
NS_IMETHODIMP nsFileUploadContentStream::ReadSegments(nsWriteSegmentFun fun, void *closure, uint32_t count, uint32_t *result) { *result = 0; // nothing is ever actually read from this stream if (IsClosed()) return NS_OK; if (IsNonBlocking()) { // Inform the caller that they will have to wait for the copy operation to // complete asynchronously. We'll kick of the copy operation once they // call AsyncWait. return NS_BASE_STREAM_WOULD_BLOCK; } // Perform copy synchronously, and then close out the stream. mCopyEvent->DoCopy(); nsresult status = mCopyEvent->Status(); CloseWithStatus(NS_FAILED(status) ? status : NS_BASE_STREAM_CLOSED); return status; }
nglString nuiTCPClient::GetDesc() const { nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP); nuiNetworkHost dest(0, 0, nuiNetworkHost::eTCP); GetLocalHost(source); GetDistantHost(dest); uint32 S = source.GetIP(); uint32 D = dest.GetIP(); uint8* s = (uint8*)&S; uint8* d = (uint8*)&D; nglString str; str.CFormat("%5d: %s - from %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d | i:%d / o:%d / a:%d / r:%lld / s:%lld| pool: %p%s [ %s ]", GetSocket(), IsNonBlocking() ? "NoBlock" : "Block ", s[0], s[1], s[2], s[3], ntohs(source.GetPort()), d[0], d[1], d[2], d[3], ntohs(dest.GetPort()), (int)mIn.GetSize(), (int)mOut.GetSize(), GetAvailable(), mReceived, mSent, mpPool, (mpAutoPool?" (auto)":""), mName.GetChars()); return str; }