public class NetworkClient
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
connectTimeout |
static int |
DEFAULT_CONNECT_TIMEOUT |
static int |
DEFAULT_READ_TIMEOUT |
protected static int |
defaultConnectTimeout |
protected static int |
defaultSoTimeout |
protected static java.lang.String |
encoding |
protected int |
readTimeout |
java.io.InputStream |
serverInput
Buffered stream for reading replies from server.
|
java.io.PrintStream |
serverOutput
Stream for printing to the server.
|
protected java.net.Socket |
serverSocket
Socket for communicating with server.
|
Constructor and Description |
---|
NetworkClient() |
NetworkClient(java.lang.String host,
int port)
Create connection with host host on port port
|
Modifier and Type | Method and Description |
---|---|
void |
closeServer()
Close an open connection to the server.
|
protected java.net.Socket |
createSocket()
The following method, createSocket, is provided to allow the https client to override it so that it may use its
socket factory to create the socket.
|
protected java.net.Socket |
doConnect(java.lang.String server,
int port)
Return a socket connected to the server, with any appropriate options pre-established
|
int |
getConnectTimeout() |
int |
getReadTimeout() |
void |
openServer(java.lang.String server,
int port)
Open a connection to the server.
|
boolean |
serverIsOpen()
Return server connection status
|
void |
setConnectTimeout(int timeout) |
void |
setReadTimeout(int timeout)
Sets the read timeout.
|
public static final int DEFAULT_READ_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
@Nullable protected java.net.Socket serverSocket
@Nullable public java.io.PrintStream serverOutput
@Nullable public java.io.InputStream serverInput
protected static int defaultSoTimeout
protected static int defaultConnectTimeout
protected int readTimeout
protected int connectTimeout
protected static java.lang.String encoding
public NetworkClient(java.lang.String host, int port) throws java.io.IOException
java.io.IOException
public NetworkClient()
public void openServer(java.lang.String server, int port) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
protected java.net.Socket doConnect(java.lang.String server, int port) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
protected java.net.Socket createSocket() throws java.io.IOException
java.io.IOException
public void closeServer() throws java.io.IOException
java.io.IOException
public boolean serverIsOpen()
public void setConnectTimeout(int timeout)
public int getConnectTimeout()
public void setReadTimeout(int timeout)
public int getReadTimeout()