Class DHCPSocket
- java.lang.Object
-
- java.net.DatagramSocket
-
- com.github.markusbernhardt.proxy.search.wpad.dhcp.DHCPSocket
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DHCPSocket extends DatagramSocket
This class represents a Socket for sending DHCP Messages- Author:
- Markus Bernhardt, Copyright 2016, Jason Goldschmidt and Simon Frankenberger, Bernd Rosstauscher, Copyright 2009
- See Also:
DatagramSocket
-
-
Constructor Summary
Constructors Constructor Description DHCPSocket(int inPort)Constructor for creating DHCPSocket on a specific port on the local machine.DHCPSocket(int inPort, InetAddress lAddr)Constructor for creating DHCPSocket on a specific local address and port on the local machine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMTU()Returns the set MTU for this socketbooleanreceive(DHCPMessage outMessage)Receives a datagram packet containing a DHCP Message into a DHCPMessage object.voidsend(DHCPMessage inMessage)Sends a DHCPMessage object to a predefined host.voidsetMTU(int inSize)Sets the Maximum Transfer Unit for the UDP DHCP Packets to be set.-
Methods inherited from class java.net.DatagramSocket
bind, close, connect, connect, disconnect, getBroadcast, getChannel, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getOption, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isBound, isClosed, isConnected, receive, send, setBroadcast, setDatagramSocketImplFactory, setOption, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass, supportedOptions
-
-
-
-
Constructor Detail
-
DHCPSocket
public DHCPSocket(int inPort) throws SocketExceptionConstructor for creating DHCPSocket on a specific port on the local machine.- Parameters:
inPort- The port for the application to bind.- Throws:
SocketException- As thrown by theSocketconstructor
-
DHCPSocket
public DHCPSocket(int inPort, InetAddress lAddr) throws SocketExceptionConstructor for creating DHCPSocket on a specific local address and port on the local machine.- Parameters:
inPort- The port for the application to bind.lAddr- The local address for the application to bind.- Throws:
SocketException- As thrown by theSocketconstructor
-
-
Method Detail
-
setMTU
public void setMTU(int inSize)
Sets the Maximum Transfer Unit for the UDP DHCP Packets to be set.- Parameters:
inSize- Integer representing desired MTU
-
getMTU
public int getMTU()
Returns the set MTU for this socket- Returns:
- The Maximum Transfer Unit set for this socket
-
send
public void send(DHCPMessage inMessage) throws IOException
Sends a DHCPMessage object to a predefined host.- Parameters:
inMessage- Well-formed DHCPMessage to be sent to a server- Throws:
IOException- If the message could not be sent.
-
receive
public boolean receive(DHCPMessage outMessage)
Receives a datagram packet containing a DHCP Message into a DHCPMessage object.- Parameters:
outMessage- DHCPMessage object to receive new message into- Returns:
trueif message is received,falseif timeout occurs.
-
-