|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.DatagramSocketImpl | +--com.act365.net.GeneralDatagramSocketImpl
GeneralDatagramSocketImpl extends java.net.DatagramSocketImpl
and provides native implementations of all of its abstract methods. The
class remains abstract because it leaves its create()
method
undefined - it is up to subclasses to specify the parameters that will
be used to create the underlying socket.
Fields inherited from interface java.net.SocketOptions |
IP_MULTICAST_IF, SO_BINDADDR, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY |
Constructor Summary | |
GeneralDatagramSocketImpl()
|
Method Summary | |
void |
bind(int localPort,
java.net.InetAddress inetAddress)
Binds this socket to a local port. |
void |
close()
Closes this socket. |
void |
create(int socketType,
int protocol,
boolean headerincluded)
Creates a new unconnected socket. |
java.lang.Object |
getOption(int optID)
Gets the value of a socket option. |
static int |
getSocketDescriptor(java.io.FileDescriptor fd)
Gets the socket descriptor from a java.io.FileDescriptor object. |
int |
getTimeToLive()
Retrieves time-to-live for multicast sockets. |
byte |
getTTL()
Retrieves time-to-live for multicast sockets. |
void |
join(java.net.InetAddress groupAddr)
Joins a multicast group. |
void |
joinGroup(java.net.SocketAddress mcastaddr,
java.net.NetworkInterface netIf)
Joins a multicast group. |
void |
leave(java.net.InetAddress groupAddr)
Leaves a multicast group. |
void |
leaveGroup(java.net.SocketAddress mcastaddr,
java.net.NetworkInterface netIf)
Leaves a multicast group. |
int |
peek(java.net.InetAddress sender)
Polls until a datagram packet is received. |
int |
peekData(java.net.DatagramPacket p)
Extracts the next DatagramPacket and returns the port number. |
void |
receive(java.net.DatagramPacket dgram)
Reads a datagram packet. |
void |
send(java.net.DatagramPacket dgram)
Sends a datagram packet. |
void |
setOption(int optID,
java.lang.Object value)
Sets the value of a socket option. |
static void |
setSocketDescriptor(java.io.FileDescriptor fd,
int sd)
Sets the socket descriptor for a java.io.FileDescriptor object. |
void |
setTimeToLive(int ttl)
Sets time-to-live for multicast sockets. |
void |
setTTL(byte ttl)
Sets time-to-live for multicast sockets. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GeneralDatagramSocketImpl()
Method Detail |
public void create(int socketType, int protocol, boolean headerincluded) throws java.net.SocketException
create()
- note no arguments - should be defined in a subclass
and call the version in the superclass with the parameters set
appropriately. When a raw socket is set up, the user has the option to write
his own IP header sockets (set headerincluded
to true
)
or to allow the operating system to write the headers. NB The option does
not exist on Windows, where the IP_HDRINCL
symbol is
unsupported.socketType
- the socket type as defined in SocketConstants
e.g. SOCK_RAWprotocol
- the protocol as defined in SocketConstants
e.g. IPPROTO_UDPheaderincluded
- whether the user will complete the IP headerSocketConstants
public void bind(int localPort, java.net.InetAddress inetAddress) throws java.net.SocketException
localPort
- number of the local portinetAddress
- local IP addresspublic void close()
public int peek(java.net.InetAddress sender) throws java.io.IOException
int
. Note that the JDK1.4 API
documentation states that the IP address should be returned as an int
- however, the JDK1.1 API documentation states that the port number should be
returned. I have implemented the JDK1.1 behaviour because it seems more
sensible - an IP address is always stored in an InetAddress
object in Java.sender
- address of sender - to be populated by the function callpublic int peekData(java.net.DatagramPacket p) throws java.io.IOException
p
- next packet receivedpeek
public void receive(java.net.DatagramPacket dgram) throws java.io.IOException
dgram
- packet to be populatedpublic void send(java.net.DatagramPacket dgram) throws java.io.IOException
dgram
- packet to be sentpublic int getTimeToLive() throws java.io.IOException
public byte getTTL() throws java.io.IOException
java.net.DatagramSocketImpl
is to be extended.public void join(java.net.InetAddress groupAddr) throws java.io.IOException
public void joinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf) throws java.io.IOException
public void leave(java.net.InetAddress groupAddr) throws java.io.IOException
public void leaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf) throws java.io.IOException
public void setTimeToLive(int ttl) throws java.io.IOException
public void setTTL(byte ttl) throws java.io.IOException
java.net.DatagramSocketImpl
is to be extended.public static int getSocketDescriptor(java.io.FileDescriptor fd)
java.io.FileDescriptor
object.
NB Java provides no public access to the value of the descriptor so
it has to be extracted using native code.public static void setSocketDescriptor(java.io.FileDescriptor fd, int sd)
java.io.FileDescriptor
object.
NB Java provides no public access to the descriptor so its value has to
be set using native code.public void setOption(int optID, java.lang.Object value) throws java.net.SocketException
Integer
object.setOption
in class java.net.DatagramSocketImpl
optID
- option as defined in java.net.SocketConstants
value
- an Integer
object that wraps the new valuepublic java.lang.Object getOption(int optID) throws java.net.SocketException
Integer
object.getOption
in class java.net.DatagramSocketImpl
optID
- option as defined in java.net.SocketConstants
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |