org.opcfoundation.ua.utils.asyncsocket
Class AsyncServerSocket

java.lang.Object
  extended by org.opcfoundation.ua.utils.AbstractState<ServerSocketState,IOException>
      extended by org.opcfoundation.ua.utils.asyncsocket.AsyncServerSocket
All Implemented Interfaces:
IStatefulObject<ServerSocketState,IOException>

public class AsyncServerSocket
extends AbstractState<ServerSocketState,IOException>

ASyncoronous Server Socket

Author:
Toni Kalajainen (toni.kalajainen@vtt.fi)

Nested Class Summary
static interface AsyncServerSocket.ConnectListener
           
 
Constructor Summary
AsyncServerSocket(ServerSocketChannel chan, Executor e)
          Constructor for AsyncServerSocket.
AsyncServerSocket(ServerSocketChannel chan, Executor e, AsyncSelector sel)
          Constructor for AsyncServerSocket.
 
Method Summary
 void addListener(AsyncServerSocket.ConnectListener listener)
          addListener.
 AsyncServerSocket bind(SocketAddress addr, int backlog)
          Binds the ServerSocket to a specific address (IP address and port number).
 ServerSocketChannel channel()
          channel.
 AsyncServerSocket close()
          close.
 void removeListener(AsyncServerSocket.ConnectListener listener)
          removeListener.
 ServerSocket socket()
          socket.
 String toString()
          
 
Methods inherited from class org.opcfoundation.ua.utils.AbstractState
addStateListener, addStateNotifiable, assertNoError, attemptSetState, clearError, getError, getState, hasError, isStateTransitionAllowed, onListenerException, onStateTransition, removeStateListener, removeStateNotifiable, setError, setState, setState, waitForState, waitForState, waitForStateUninterruptibly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AsyncServerSocket

public AsyncServerSocket(ServerSocketChannel chan,
                         Executor e,
                         AsyncSelector sel)
                  throws ClosedChannelException

Constructor for AsyncServerSocket.

Parameters:
chan - a ServerSocketChannel object.
e - a Executor object.
sel - a AsyncSelector object.
Throws:
ClosedChannelException - if any.

AsyncServerSocket

public AsyncServerSocket(ServerSocketChannel chan,
                         Executor e)
                  throws IOException

Constructor for AsyncServerSocket.

Parameters:
chan - a ServerSocketChannel object.
e - a Executor object.
Throws:
IOException - if any.
Method Detail

bind

public AsyncServerSocket bind(SocketAddress addr,
                              int backlog)
                       throws IOException
Binds the ServerSocket to a specific address (IP address and port number).

If the address is null, then the system will pick up an ephemeral port and a valid local address to bind the socket.

The backlog argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.

Parameters:
addr - address
backlog - backlog
Returns:
this object. This is used for chained invocation
Throws:
IllegalArgumentException - if endpoint is a SocketAddress subclass not supported by this socket
IOException - if error

close

public AsyncServerSocket close()

close.

Returns:
a AsyncServerSocket object.

channel

public ServerSocketChannel channel()

channel.

Returns:
a ServerSocketChannel object.

socket

public ServerSocket socket()

socket.

Returns:
a ServerSocket object.

addListener

public void addListener(AsyncServerSocket.ConnectListener listener)

addListener.

Parameters:
listener - a AsyncServerSocket.ConnectListener object.

removeListener

public void removeListener(AsyncServerSocket.ConnectListener listener)

removeListener.

Parameters:
listener - a AsyncServerSocket.ConnectListener object.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2018. All rights reserved.