public class NetworkClient extends 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 String |
encoding |
protected int |
readTimeout |
InputStream |
serverInput
Buffered stream for reading replies from server.
|
PrintStream |
serverOutput
Stream for printing to the server.
|
protected Socket |
serverSocket
Socket for communicating with server.
|
Constructor and Description |
---|
NetworkClient() |
NetworkClient(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 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 Socket |
doConnect(String server,
int port)
Return a socket connected to the server, with any appropriate options pre-established
|
int |
getConnectTimeout() |
int |
getReadTimeout() |
void |
openServer(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.
|
protected int connectTimeout
public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT
protected static int defaultConnectTimeout
protected static int defaultSoTimeout
protected static String encoding
protected int readTimeout
@Nullable public InputStream serverInput
@Nullable public PrintStream serverOutput
public NetworkClient()
public NetworkClient(String host, int port) throws IOException
IOException
public void closeServer() throws IOException
IOException
protected Socket createSocket() throws IOException
IOException
protected Socket doConnect(String server, int port) throws IOException, UnknownHostException
IOException
UnknownHostException
public int getConnectTimeout()
public int getReadTimeout()
public void openServer(String server, int port) throws IOException, UnknownHostException
IOException
UnknownHostException
public boolean serverIsOpen()
public void setConnectTimeout(int timeout)
public void setReadTimeout(int timeout)