dontFragment
The don't fragment flag. The socket must be initialized before calling this function.
Readonly
localReturns the local address of this UDP socket
multicastInterface
The interface that should be used for sending future multicast datagrams. Note: This is currently write-only.
multicastInterfaceAddr
The interface that should be used for sending future multicast datagrams. Note: This is currently write-only.
multicastLoopback
Whether multicast datagrams sent via this socket should be looped back to this host (assuming this host has joined the relevant group). Defaults to true. Note: This is currently write-only.
Readonly
portReturns the port of this UDP socket.
recvBufferSize
The size of the receive buffer. Default depends on the OS.
sendBufferSize
The size of the send buffer. Default depends on the OS.
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
asyncListen
This method puts the UDP socket in the listening state. It will asynchronously listen for and accept client connections. The listener will be notified once for each client connection that is accepted. The listener's onSocketAccepted method will be called on the same thread that called asyncListen (the calling thread must have a nsIEventTarget).
The listener will be passed a reference to an already connected socket transport (nsISocketTransport). See below for more details.
The listener to be notified when client connections are accepted.
Returns the address to which this UDP socket is bound. Since a UDP socket may be bound to multiple network devices, this address may not necessarily be specific to a single network device. In the case of an IP socket, the IP address field would be zerod out to indicate a UDP socket bound to all network devices. Therefore, this method cannot be used to determine the IP address of the local system. See nsIDNSService::myHostName if this is what you need.
init
This method initializes a UDP socket.
The port of the UDP socket. Pass -1 to indicate no preference, and a port will be selected automatically.
If true, the UDP socket will only respond to connections on the local loopback interface. Otherwise, it will accept connections from any interface. To specify a particular network interface, use initWithAddress.
The principal connected to this socket.
If true, the socket is allowed to be bound to an address that is already in use. Default is true.
initWithAddress
This method initializes a UDP socket, and binds it to a particular local address (and hence a particular local network interface).
The address to which this UDP socket should be bound.
The principal connected to this socket.
If true, the socket is allowed to be bound to an address that is already in use. Default is true.
joinMulticast
Join the multicast group specified by |addr|. You are then able to receive future datagrams addressed to the group.
The multicast group address.
The local address of the interface on which to join the group. If this is not specified, the OS may join the group on all interfaces or only the primary interface.
leaveMulticast
Leave the multicast group specified by |addr|. You will no longer receive future datagrams addressed to the group.
The multicast group address.
The local address of the interface on which to leave the group. If this is not specified, the OS may leave the group on all interfaces or only the primary interface.
send
Send out the datagram to specified remote host and port. DNS lookup will be triggered.
number of bytes written. (0 or length of data)
The remote host name.
The remote port.
The buffer containing the data to be written.
sendBinaryStream
Send out the datagram to specified remote address and port.
The remote host name.
The remote port.
The input stream to be sent. This must be a buffered stream implementation.
sendBinaryStreamWithAddress
Send out the datagram to specified remote address and port.
The remote host address.
The input stream to be sent. This must be a buffered stream implementation.
sendWithAddr
Send out the datagram to specified remote host and port.
number of bytes written. (0 or length of data)
The remote host address.
The buffer containing the data to be written.
sendWithAddress
Send out the datagram to specified remote address and port.
number of bytes written. (0 or length of data)
The remote host address.
The buffer containing the data to be written.
This adds a nsIUDPSocketSyncListener listener (defined below). When data is available onPacketReceived is called and the lisener uses recvWithAddr to actually retrive data from the socket. The listener can be use only if it runs on the socket thread. If it is used off the socket thread there is a risk of triggering a bug in OS thatcan cause a crash.
Generated using TypeDoc
nsIUDPSocket
An interface to a UDP socket that can accept incoming connections.