Atavism Version 2018.1AGIS API

atavism.server.network
Class TcpServer

java.lang.Object
  extended by atavism.server.network.TcpServer

public class TcpServer
extends java.lang.Object

binds on a port and accepts new connections on its own private thread. calls registered callback on accepting a new connection.


Field Summary
protected  TcpAcceptCallback acceptCallback
           
protected static Logger log
           
protected  java.nio.channels.ServerSocketChannel ssChannel
           
protected  java.lang.Thread thread
           
 
Constructor Summary
TcpServer()
           
TcpServer(int port)
           
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acceptCallback

protected TcpAcceptCallback acceptCallback

ssChannel

protected java.nio.channels.ServerSocketChannel ssChannel

thread

protected java.lang.Thread thread

log

protected static final Logger log
Constructor Detail

TcpServer

public TcpServer()

TcpServer

public TcpServer(int port)
Method Detail

bind

public void bind()
          throws java.io.IOException
binds to a random local port and the wildcard address

Throws:
java.io.IOException

bind

public void bind(int port)
          throws java.io.IOException
binds to specified tcp port and the wildcard address, and starts accepting incoming connections

Throws:
java.io.IOException

bind

public void bind(java.lang.String hostname,
                 int port)
          throws java.io.IOException
binds to specified tcp port and the address matching the specified hostname, and starts accepting incoming connections

Throws:
java.io.IOException

bind

public void bind(java.net.InetAddress address,
                 int port)
          throws java.io.IOException
binds to specified tcp port and the specified address, and starts accepting incoming connections

Throws:
java.io.IOException

bind

public void bind(java.net.InetSocketAddress address)
          throws java.io.IOException
Throws:
java.io.IOException

getPort

public int getPort()

getAddress

public java.net.InetAddress getAddress()

registerAcceptCallback

public void registerAcceptCallback(TcpAcceptCallback cb)

getThread

public java.lang.Thread getThread()

start

public void start()
start processing new incoming connections and also handle requests



Copyright © 2018 Dragonsan Studios Sp. z o.o.