How to get socket descriptor from nsISocketTransport
I am trying to obtain socket descriptor from a Socket Transport
object. However, I am unable to obtain a valid descriptor, and I was
wondering if some one could point out what I am doing wrong. Here is
what I am doing to get socket descriptor:
using a SocketTransportService object:
var currTransport = mySockService.createTransport(null, 0,
currHostName, currPort, null);
2. Now, I am passing currTransport to a C++ xpcom component as an
object with interface nsISocketTransport. In the C++ code, I call
GetFileDescriptor on the currTransport object.
NS_IMETHODIMP getDescFromTransport(nsISocketTransport *sockTransport)
I noticed that after calling GetFileDescriptor, fd is set to a null
I think fd should not contain a null value and should point to the
socket descriptor for the socket connection that has been established.
Please let me know if this is the expected behaviour. Do I need to do
something more with sockTransport in order to obtain a valid file
descriptor using GetFileDescriptor()?
Christian Biesinger wrote:
> Abhijit wrote:
> > if (NS_FAILED(sockTransport->GetFileDescriptor(&fd)))
> (Wjat's GetFileDescriptor? I can't find such a function in my Gecko
> source code)
Yes, GetFileDescriptor is not a member in the IDL file for
> > I think fd should not contain a null value and should point to the
> > socket descriptor for the socket connection that has been established.
> You'll have to wait until DNS resolution is complete at least, no? It'd
> probably be wise to wait until the connection is established too.
> That is, wait for a STATUS_CONNECTING_TO (DNS lookup complete, socket
> created, connecting) or STATUS_CONNECTED_TO (connection established)
> message (via nsITransportEventSink).
I agree. I tried accessing the file descriptor after sending and
receiving data on the Socket Transport (via input and output streams)
and I did get a valid socket descriptor.