public class ClientSocket
extends java.net.Socket
Socket
adding new useful methods
and other ones has been overrided and adapted to new requirements.Modifier and Type | Field and Description |
---|---|
private boolean |
connected |
static int |
DEFAULT_PORT
The default port.
|
private int |
DEFAULT_TIMEOUT |
private int |
port
It is the server port where request must be sent.
|
private java.lang.String |
server
Contains the JPIP server name.
|
private int |
timeout |
Constructor and Description |
---|
ClientSocket() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
connect(java.lang.String server)
Opens a connection between the client and the server.
|
void |
connect(java.lang.String server,
int port)
Opens a connection between the client and the server.
|
void |
connect(java.lang.String server,
int port,
int timeout)
Opens a connection between the client and the server.
|
java.io.InputStream |
getInputStream() |
java.io.OutputStream |
getOutputStream() |
java.lang.String |
getRemoteHost()
Returns the name of the endpoint this client is connected to, or null if
it is unconnected.
|
boolean |
isConnected() |
void |
list(java.io.PrintStream out)
Prints this ClientSocket out to the specified output stream.
|
void |
reconnect()
Reconnects the socket using the last server, port, and timeout.
|
void |
setSoTimeout(int timeout) |
java.lang.String |
toString()
For debugging purposes.
|
bind, connect, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput
private java.lang.String server
private int port
public static final int DEFAULT_PORT
private int timeout
private int DEFAULT_TIMEOUT
private boolean connected
public void connect(java.lang.String server) throws java.io.IOException
close()
method is called.server
- the server name.java.io.IOException
- an IOException will be thrown is the connection
can not be opened.public void connect(java.lang.String server, int port) throws java.io.IOException
close()
method is called.server
- port
- java.io.IOException
- an IOException will be thrown is the connection
can not be opened.public void connect(java.lang.String server, int port, int timeout) throws java.io.IOException
close()
method is called.server
- port
- timeout
- java.io.IOException
- an IOException will be thrown is the connection
can not be opened.public void reconnect() throws java.io.IOException
java.io.IOException
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.net.Socket
public boolean isConnected()
isConnected
in class java.net.Socket
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in class java.net.Socket
java.io.IOException
public java.io.OutputStream getOutputStream() throws java.io.IOException
getOutputStream
in class java.net.Socket
java.io.IOException
public java.lang.String getRemoteHost()
public void setSoTimeout(int timeout) throws java.net.SocketException
setSoTimeout
in class java.net.Socket
java.net.SocketException
public java.lang.String toString()
toString
in class java.net.Socket
public void list(java.io.PrintStream out)
out
- an output stream.
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)