Closed Bug 79876 Opened 24 years ago Closed 21 years ago

nsSocketBIS::Available() is not implemented

Categories

(Core :: Networking, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED FIXED
Future

People

(Reporter: rginda, Assigned: darin.moz)

Details

I'm not sure why not, I'm guessing it was just overlooked. Index: nsSocketTransport.cpp =================================================================== RCS file: /cvsroot/mozilla/netwerk/base/src/nsSocketTransport.cpp,v retrieving revision 1.200 diff -u -r1.200 nsSocketTransport.cpp --- nsSocketTransport.cpp 2001/04/16 21:01:03 1.200 +++ nsSocketTransport.cpp 2001/05/09 23:50:07 @@ -1976,7 +1976,13 @@ NS_IMETHODIMP nsSocketBIS::Available(PRUint32 *aCount) { - return NS_ERROR_NOT_IMPLEMENTED; + PRFileDesc *sock = GetSocket(); + NS_ENSURE_TRUE(sock, NS_ERROR_NOT_AVAILABLE); + PRInt32 avail = PR_Available (sock); + if (avail < 0) + return NS_ERROR_FAILURE; + *aCount = NS_STATIC_CAST(PRUint32, avail); + return NS_OK; } NS_IMETHODIMP
-->darin
Assignee: neeti → darin
As it turns out when we had some problems with calling PR_Available on a socket on BeOS and MacOS. We'd really want to do some testing of this routine before commiting this patch.
Target Milestone: --- → Future
mass move, v2. qa to me.
QA Contact: tever → benc
Note that one implication of this is that nsScriptableInputStream::Read() will always fail when reading from a socket, meaning, at the very least, that you cannot read sockets from JavaScript. Axel Hecht suggested that perhaps nsScriptableInputStream::Read() should just allocate the full buffer size when the nsIInputStream::Available() fails, rather than failing in turn.
Chatzilla reads sockets from javascript just fine, using the async calls. See <http://lxr.mozilla.org/mozilla/source/extensions/irc/js/lib/connection-xpcom.js>.
yeah, i think you should avoid the blocking i/o calls unless you are running code on a background thread since you don't want to hang the browser UI by waiting on a socket connection.
nsSocketBIS is gone, along with nsSocketTransport.cpp. nsSocketInputStream::Available is implemented. http://lxr.mozilla.org/seamonkey/source/netwerk/base/src/nsSocketTransport2.cpp#262 this happened as part of bug 176919 --> marking fixed.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
V/fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.