public class SocketServer
extends java.lang.Object
This server must be linked to a Router
.
Requests can be send as plain text requests or as http get requests. You can then easily use your browser to send requests to this server.
Example of use: SocketServerExample
Modifier and Type | Field and Description |
---|---|
protected int |
port
Port used by the socket server.
|
protected Router |
router
The Raspoid Router used by this server.
|
protected java.util.List<java.lang.String> |
serverIpAddresses
List of available ip addresses to access the socket server.
|
Constructor and Description |
---|
SocketServer(int maxNbOfConnections,
int port,
Router router)
Constructor for a simple socket server using the specified parameters.
|
SocketServer(Router router)
Constructor for a simple socket server using the specified Router
and with the following parameter values:
Maximum number of connections: 5
Port number: Network.getAvailablePort()
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Turns the Raspoid socket server off.
|
java.util.List<java.lang.String> |
getIpAddresses()
Get the list of ip addresses linked to this server.
|
int |
getPort()
Get the port used by the server.
|
protected void |
newThreadToDealWithClient(java.net.Socket client) |
void |
pause()
Turns the Raspoid server in a pause mode.
|
protected void |
printServerLaunchedMessage() |
void |
start()
Turns the Raspoid server on.
|
protected java.util.List<java.lang.String> serverIpAddresses
protected int port
public SocketServer(Router router)
router
- the Raspoid router to use with this socket server.public SocketServer(int maxNbOfConnections, int port, Router router)
maxNbOfConnections
- the maximum number of parallel connections allowed on this server.port
- the port to use with this server.router
- the Raspoid router to use with this socket server.protected void newThreadToDealWithClient(java.net.Socket client)
protected void printServerLaunchedMessage()
public void start()
pause()
public void pause()
All requests are then rejected. You can use the start() method to relaunch the server.
start()
public void close()
public java.util.List<java.lang.String> getIpAddresses()
public int getPort()