Package net.i2p.router.transport.udp
Class UDPEndpoint
java.lang.Object
net.i2p.router.transport.udp.UDPEndpoint
- All Implemented Interfaces:
SocketListener
Coordinate the low-level datagram socket, creating and managing the UDPSender and
UDPReceiver.
-
Constructor Summary
ConstructorsConstructorDescriptionUDPEndpoint(RouterContext ctx, UDPTransport transport, int listenPort, InetAddress bindAddress) -
Method Summary
Modifier and TypeMethodDescriptionvoidClear outbound queue, probably in preparation for sending destroy() to everybody.voidfail()intcall after startup() to get actual port or -1 on startup failurebooleanisIPv4()booleanisIPv6()receive()Blocking call to receive the next inbound UDP packet from any peer.voidAdd the packet to the outobund queue to be sent ASAP (as allowed by the bandwidth limiter) BLOCKING if queue is full.voidsetListenPort(int newPort) voidshutdown()voidstartup()Caller should call getListenPort() after this to get the actual bound port and determine success .toString()
-
Constructor Details
-
UDPEndpoint
public UDPEndpoint(RouterContext ctx, UDPTransport transport, int listenPort, InetAddress bindAddress) - Parameters:
transport- may be null for unit testing ONLYlistenPort- -1 or the requested port, may not be honoredbindAddress- null ok
-
-
Method Details
-
startup
Caller should call getListenPort() after this to get the actual bound port and determine success . Can be restarted.- Throws:
SocketException
-
shutdown
public void shutdown() -
setListenPort
public void setListenPort(int newPort) -
getListenPort
public int getListenPort()call after startup() to get actual port or -1 on startup failure -
getSender
-
send
Add the packet to the outobund queue to be sent ASAP (as allowed by the bandwidth limiter) BLOCKING if queue is full. -
receive
Blocking call to receive the next inbound UDP packet from any peer. UNIT TESTING ONLY. Direct from the socket. In normal operation, UDPReceiver thread injects to PacketHandler queue.- Returns:
- null if we have shut down, or on failure
-
clearOutbound
public void clearOutbound()Clear outbound queue, probably in preparation for sending destroy() to everybody.- Since:
- 0.9.2
-
isIPv4
public boolean isIPv4()- Returns:
- true for wildcard too
- Since:
- IPv6
-
isIPv6
public boolean isIPv6()- Returns:
- true for wildcard too
- Since:
- IPv6
-
fail
public void fail()- Specified by:
failin interfaceSocketListener- Since:
- 0.9.16
-
toString
-