public class IceTcpServerSocketWrapper extends IceSocketWrapper
Modifier and Type | Class and Description |
---|---|
private class |
IceTcpServerSocketWrapper.ThreadAccept
Thread that will wait for new TCP connections.
|
Modifier and Type | Field and Description |
---|---|
private Thread |
acceptThread
Thread that will wait new connections.
|
private Component |
component
STUN stack.
|
private boolean |
isRun
If the socket is still listening.
|
private static Logger |
logger
The Logger used by the LocalCandidate class and its
instances for logging output.
|
private ServerSocket |
serverSocket
The wrapped TCP ServerSocket.
|
private List<Socket> |
sockets
List of TCP client sockets.
|
Constructor and Description |
---|
IceTcpServerSocketWrapper(ServerSocket serverSocket,
Component component)
Initializes a new IceTcpServerSocketWrapper.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this socket.
|
InetAddress |
getLocalAddress()
Get local address.
|
int |
getLocalPort()
Get local port.
|
SocketAddress |
getLocalSocketAddress()
Get socket address.
|
Socket |
getTCPSocket()
Returns Socket object if the delegate socket is a TCP one, null
otherwise.
|
DatagramSocket |
getUDPSocket()
Returns DatagramSocket object if the delegate socket is a UDP one, null
otherwise.
|
void |
receive(DatagramPacket p)
Receives a DatagramPacket from this socket.
|
void |
send(DatagramPacket p)
Sends a DatagramPacket from this socket
It is a utility method to provide a common way to send for both
UDP and TCP socket.
|
private static final Logger logger
private Thread acceptThread
private final ServerSocket serverSocket
private boolean isRun
private final Component component
public IceTcpServerSocketWrapper(ServerSocket serverSocket, Component component)
serverSocket
- TCP ServerSocketcomponent
- related Componentpublic void send(DatagramPacket p) throws IOException
send
in class IceSocketWrapper
p
- DatagramPacket to sendIOException
- if something goes wrongpublic void receive(DatagramPacket p) throws IOException
receive
in class IceSocketWrapper
p
- DatagramPacketIOException
- if something goes wrongpublic void close()
close
in class IceSocketWrapper
public InetAddress getLocalAddress()
getLocalAddress
in class IceSocketWrapper
public int getLocalPort()
getLocalPort
in class IceSocketWrapper
public SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class IceSocketWrapper
public Socket getTCPSocket()
getTCPSocket
in class IceSocketWrapper
public DatagramSocket getUDPSocket()
getUDPSocket
in class IceSocketWrapper
Copyright © 2018. All rights reserved.