|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.DatagramSocket | +--edu.uiuc.cs.net.DPRPManager.DPRPSocket
This class represents a Socket for sending DPRP Messages. It was adapted
from the JDHCP package, available at http://www.dhcp.org/javadhcp/main.html.
This package implements a simple DHCP client in Java, and was the
inspiration for a lot of the DPRP code base. However, this is the
only file that was actually ripped from the JDHCP distribution, and
adapted to the DPRP cause. Aside from some major tweaks to
receive()
, I pretty much just did a search-and-replace
job.
DatagramSocket
Field Summary | |
private int |
defaultRcvTIME_OUT
Default receive socket timeout (defaults to 4 seconds). |
private int |
defaultSndTIME_OUT
Default send timeout (defaults to 2 seconds). |
private int |
defaultSOTIME_OUT
Default socket timeout (defaults to 4 seconds). |
protected static int |
PACKET_SIZE
The size of a packet -- defaults to 1500 bytes (Ethernet MTU). |
Fields inherited from class java.net.DatagramSocket |
connected, connectedAddress, connectedPort, factory, impl, implClass |
Constructor Summary | |
DPRPSocket()
Constructor for creating a DPRPSocket on the "next available" local port on the machine. |
|
DPRPSocket(int inPort)
Constructor for creating DPRPSocket on a specific port on the local machine. |
|
DPRPSocket(int inPort,
java.net.InetAddress laddr)
Constructor, that binds the new socket to a specific IP address & port combination. |
Method Summary | |
int |
getMTU()
Returns the set MTU for this socket |
boolean |
receive(DPRPMessage outMessage)
Receives a datagram packet containing a DHCP Message into a DHCPMessage object. |
void |
send(DPRPMessage inMessage)
Sends a DHCPMessage object to a predifined host. |
void |
sendError(DPRPMessage errMsg,
int errno)
A method that I crafted, that sends an error message. |
void |
setMTU(int inSize)
Sets the Maximum Transfer Unit for the UDP DHCP Packets to be set. |
Methods inherited from class java.net.DatagramSocket |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Field Detail |
protected static int PACKET_SIZE
private int defaultSOTIME_OUT
private int defaultRcvTIME_OUT
private int defaultSndTIME_OUT
Constructor Detail |
public DPRPSocket() throws java.net.SocketException
java.net.SocketException
- If the socket cannot be created/bound.public DPRPSocket(int inPort) throws java.net.SocketException
inPort
- the port for the application to bind.java.net.SocketException
- If the socket cannot be created/bound.public DPRPSocket(int inPort, java.net.InetAddress laddr) throws java.net.SocketException
inPort
- The port to which we should attempt our bind.laddr
- The local IP address to which we should attempt to bind.java.net.SocketException
- If the socket cannot be created/bound.Method Detail |
public void setMTU(int inSize)
inSize
- integer representing desired MTUpublic int getMTU()
public void send(DPRPMessage inMessage) throws java.io.IOException
synchronized
flag,
which enforces a monitor lock, and makes all calls to this
method ordered. I have lifted this flag, because the way I use
this method, only one thread will ever be hitting upon a
specific socket at a time.inMessage
- well-formed DHCPMessage to be sent to a serverpublic boolean receive(DPRPMessage outMessage)
synchronized
restriction here.outMessage
- DHCPMessage object to receive new message intopublic void sendError(DPRPMessage errMsg, int errno)
errMsg
- A message to send, with the proper source and destination
addresses set.errno
- An error number, to stuff into the message before sending.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |