public class MultiplexerServer extends Object
The MultiplexerServer can be used to have multiple serversockets that a MultiplexerClient can then make
many connections through a single real socket.
This is useful for situations where multiple real connections are undesired because of
routing/loadbalance and connection management issues.
An MultiplexerClient can then have a single connection to a server and then have multiple connections through this connection.
Constructor and Description |
---|
MultiplexerServer(int port) |
MultiplexerServer(String host,
int port)
Creates a new server that allows for multiplexing many client connections over a single real
connection.
|
Modifier and Type | Method and Description |
---|---|
VirtualServerSocket |
createServerSocket(String serverSocketName)
Creates a serverSocket (virtual) through the real socket.
|
int |
getCreatedConnectionCount() |
String |
getHost()
Host name.
|
String |
getInvalidConnectionMessage() |
int |
getLiveConnectionCount() |
int |
getPort()
Server listen port.
|
long |
getReadCount() |
long |
getReadSize() |
int |
getThrottleLimit() |
long |
getWriteCount() |
long |
getWriteSize() |
boolean |
isStarted() |
protected void |
onClientConnect(Socket socket,
int connectionId)
Called when a real socket connection is made.
|
protected void |
onClientDisconnect(int connectionId)
Called when a real socket is disconnected.
|
void |
setInvalidConnectionMessage(String msg)
Message to display when a non-socket connects.
|
void |
setThrottleLimit(int mbPerSecond)
Used to set the limit on the number of bytes that can be written per second (in MB).
|
void |
start()
This must be called to enable serverSocket to begin accepting new connections.
|
void |
stop() |
void |
stopServerSocket()
Stop the serverSocket from accepting new connections.
|
public MultiplexerServer(String host, int port)
host
- nameport
- port number to connect tocall start to allow new connections from clients.
public MultiplexerServer(int port)
public void setThrottleLimit(int mbPerSecond) throws Exception
Exception
public void start() throws Exception
Exception
public void stopServerSocket() throws Exception
Exception
public boolean isStarted()
public VirtualServerSocket createServerSocket(String serverSocketName) throws IOException
serverSocketName
- unique name that will be used by clients when creating an vsocket.IOException
public int getPort()
public String getHost()
public void setInvalidConnectionMessage(String msg)
public String getInvalidConnectionMessage()
protected void onClientDisconnect(int connectionId)
protected void onClientConnect(Socket socket, int connectionId)
public long getReadCount()
public long getReadSize()
public long getWriteCount()
public long getWriteSize()
public int getCreatedConnectionCount()
public int getLiveConnectionCount()
Copyright © 1999–2019 ViaOA. All rights reserved.