From 2e3acb0592b013a2be60c4cfbade3b465e570ab5 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Tue, 2 May 2000 22:25:00 +0000 Subject: [PATCH] 28880. socket transport now provides access to the underlying ip address --- netwerk/base/public/nsISocketTransport.idl | 66 ++++++++++++---------- netwerk/base/src/nsSocketTransport.cpp | 15 +++++ 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/netwerk/base/public/nsISocketTransport.idl b/netwerk/base/public/nsISocketTransport.idl index 78a6a31e149c..1c96143e673a 100644 --- a/netwerk/base/public/nsISocketTransport.idl +++ b/netwerk/base/public/nsISocketTransport.idl @@ -25,37 +25,43 @@ [scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)] interface nsISocketTransport : nsISupports { - attribute boolean reuseConnection; + attribute boolean reuseConnection; + + /** + * socket read/write timeout in seconds; 0 = no timeout + */ + attribute unsigned long socketTimeout; + + /** + * socket connect timeout in seconds; 0 = no timeout + */ + attribute unsigned long socketConnectTimeout; + + /** + * Is used to tell the channel to stop reading data after a certain point; + * needed by HTTP/1.1 + */ + attribute long bytesExpected; + attribute unsigned long reuseCount; + + /** + * Checks if the socket is still alive + * + * @param seconds amount of time after which the socket is always deemed to be + * dead (no further checking is done in this case); seconds = 0 + * will cause it not to do the timeout checking at all + */ + boolean isAlive (in unsigned long seconds); + + /** + * maximum amount of time in seconds the transport is allowed to stay alive + * while connected (0 - default; no maximum idle timeout) + */ + attribute unsigned long idleTimeout; /** - * socket read/write timeout in seconds; 0 = no timeout + * the string representation of the underlying ip address. Caller + * is responsible for de-allocating the returned string. */ - attribute unsigned long socketTimeout; - - /** - * socket connect timeout in seconds; 0 = no timeout - */ - attribute unsigned long socketConnectTimeout; - - /** - * Is used to tell the channel to stop reading data after a certain point; - * needed by HTTP/1.1 - */ - attribute long bytesExpected; - attribute unsigned long reuseCount; - - /** - * Checks if the socket is still alive - * - * @param seconds amount of time after which the socket is always deemed to be - * dead (no further checking is done in this case); seconds = 0 - * will cause it not to do the timeout checking at all - */ - boolean isAlive (in unsigned long seconds); - - /** - * maximum amount of time in seconds the transport is allowed to stay alive - * while connected (0 - default; no maximum idle timeout) - */ - attribute unsigned long idleTimeout; + [noscript] string GetIPStr(in unsigned long aStrLen); }; diff --git a/netwerk/base/src/nsSocketTransport.cpp b/netwerk/base/src/nsSocketTransport.cpp index 2fd4fd45d36e..b0bfd235d483 100644 --- a/netwerk/base/src/nsSocketTransport.cpp +++ b/netwerk/base/src/nsSocketTransport.cpp @@ -2269,6 +2269,21 @@ nsSocketTransport::SetIdleTimeout (PRUint32 seconds) return NS_OK; } +NS_IMETHODIMP +nsSocketTransport::GetIPStr(PRUint32 aLen, char **_retval) { + NS_ASSERTION(aLen > 0, "caller must pass in str len"); + *_retval = (char*)nsAllocator::Alloc(aLen); + if (!*_retval) return NS_ERROR_FAILURE; + + PRStatus status = PR_NetAddrToString(&mNetAddress, *_retval, aLen); + + if (PR_FAILURE == status) { + nsAllocator::Free(*_retval); + return NS_ERROR_FAILURE; + } + return NS_OK; +} + NS_IMETHODIMP nsSocketTransport::GetSocketTimeout (PRUint32 * o_Seconds) {