Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

creating a UDP/IP socket with NetLib

649 views
Skip to first unread message

Charles Melhorn

unread,
Jan 29, 2003, 11:07:40 AM1/29/03
to mozilla...@mozilla.org
Hello,

I was wondering if it's possible to create a
(scriptable) UDP/IP (datagram) socket with NetLib?
Upon a cursory inspection of the code, particularly
the nsSocketTransportService::CreateTransportOfTypes()
method and related classes, it would appear that
it's only possible to create TCP/IP sockets, or
variants: tcp+SSL, tcp+TLS, tcp+SOCKS, tcp+SOCKS4.

Is that the case? And if it is, should I file an
RFE? I believe there is a portable runtime function
for creating a UDP socket, PR_NewUDPSocket(), but
I'm not sure how much more infrastructure would be
needed to support the use of datagrams in a Mozilla
extension.

Any help would be appreciated.

Thanks,

Charles

Darin Fisher

unread,
Jan 29, 2003, 1:03:58 PM1/29/03
to Charles Melhorn, mozilla...@mozilla.org


yup, this is a legitimate feature request. you can work around the
limitations of necko by registering your own nsISocketProvider. check
out the nsISocketProviderService for more details.

if you register a socket provider under the string "my-socket-type", and
if you pass this string to the CreateTransportOfType method on
nsISocketTransport, the socket transport code will call your socket
provider's NewSocket instead of the default PR_NewTCPSocket(). iow, you
can just make your socket provider call PR_NewUDPSocket() and return that.

darin

Doug Turner

unread,
Jan 29, 2003, 10:21:13 PM1/29/03
to Darin Fisher, Charles Melhorn, mozilla...@mozilla.org


This is code from about a year ago when I was playing around with UDP
applications and Mozilla. I would be surprised if this complied out of
the box.

one you get it compiling, you need to register this component with the
contract id that is specified in nsISocketProvider.

If you have question, please ask.

Doug Turner
do...@netscape.com

nsUDPSocketProvider.cpp
nsUDPSocketProvider.h
0 new messages