public class TcpServer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected TcpAcceptCallback |
acceptCallback |
protected static Logger |
log |
protected java.nio.channels.ServerSocketChannel |
ssChannel |
protected java.lang.Thread |
thread |
Modifier and Type | Method and Description |
---|---|
void |
bind()
binds to a random local port and the wildcard address
|
void |
bind(java.net.InetAddress address,
int port)
binds to specified tcp port and the specified address,
and starts accepting incoming connections
|
void |
bind(java.net.InetSocketAddress address) |
void |
bind(int port)
binds to specified tcp port and the wildcard address,
and starts accepting incoming connections
|
void |
bind(java.lang.String hostname,
int port)
binds to specified tcp port and the address matching the specified hostname,
and starts accepting incoming connections
|
java.net.InetAddress |
getAddress() |
int |
getPort() |
java.lang.Thread |
getThread() |
void |
registerAcceptCallback(TcpAcceptCallback cb) |
void |
start()
start processing new incoming connections and
also handle requests
|
protected TcpAcceptCallback acceptCallback
protected java.nio.channels.ServerSocketChannel ssChannel
protected java.lang.Thread thread
protected static final Logger log
public void bind() throws java.io.IOException
java.io.IOException
public void bind(int port) throws java.io.IOException
java.io.IOException
public void bind(java.lang.String hostname, int port) throws java.io.IOException
java.io.IOException
public void bind(java.net.InetAddress address, int port) throws java.io.IOException
java.io.IOException
public void bind(java.net.InetSocketAddress address) throws java.io.IOException
java.io.IOException
public int getPort()
public java.net.InetAddress getAddress()
public void registerAcceptCallback(TcpAcceptCallback cb)
public java.lang.Thread getThread()
public void start()