Class PTCPSocket
java.lang.Object
java.net.Socket
ecmwf.common.transport.ptcp.psocket.PTCPSocket
-
Constructor Summary
ConstructorsConstructorDescriptionPTCPSocket(int num) Instantiates a new PTCP socket.PTCPSocket(String host, int port, int num) Instantiates a new PTCP socket.PTCPSocket(String host, int port, InetAddress localAddr, int localPort, int num) Instantiates a new PTCP socket.PTCPSocket(InetAddress address, int port, int num) Instantiates a new PTCP socket.PTCPSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int num) Instantiates a new PTCP socket. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the socket.voidclose()Close.Returns the address to which the socket is connected.Returns an input stream for this socket.booleanTests if SO_KEEPALIVE is enabled.Gets the local address to which the socket is bound.intReturns the local port to which this socket is bound.Returns an output stream for this socket.intgetPort()Returns the remote port to which this socket is connected.intGets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.intGet value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.intReturns setting for SO_LINGER. -1 returns implies that the option is disabled.intReturns setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).booleanTests if TCP_NODELAY is enabled.booleanReturns the connection state of the socket.voidsetKeepAlive(boolean on) Enable/disable SO_KEEPALIVE.voidsetReceiveBufferSize(int size) Sets the SO_RCVBUF option to the specified value for this Socket.voidsetSendBufferSize(int size) Sets the SO_SNDBUF option to the specified value for this Socket.voidsetSoLinger(boolean on, int linger) Enable/disable SO_LINGER with the specified linger time in seconds.voidsetSoTimeout(int timeout) Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.voidsetTcpNoDelay(boolean on) Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).voidPlaces the input stream for this socket at "end of stream".voidDisables the output stream for this socket.toString()Converts this socket to a String.Methods inherited from class java.net.Socket
bind, connect, connect, getChannel, getLocalSocketAddress, getOOBInline, getOption, getRemoteSocketAddress, getReuseAddress, getTrafficClass, isBound, isClosed, isInputShutdown, isOutputShutdown, sendUrgentData, setOOBInline, setOption, setPerformancePreferences, setReuseAddress, setSocketImplFactory, setTrafficClass, supportedOptions
-
Constructor Details
-
PTCPSocket
public PTCPSocket(int num) Instantiates a new PTCP socket.- Parameters:
num- the num
-
PTCPSocket
Instantiates a new PTCP socket.- Parameters:
host- the hostport- the portnum- the num- Throws:
UnknownHostException- the unknown host exceptionIOException- Signals that an I/O exception has occurred.
-
PTCPSocket
Instantiates a new PTCP socket.- Parameters:
address- the addressport- the portnum- the num- Throws:
UnknownHostException- the unknown host exceptionIOException- Signals that an I/O exception has occurred.
-
PTCPSocket
public PTCPSocket(String host, int port, InetAddress localAddr, int localPort, int num) throws UnknownHostException, IOException Instantiates a new PTCP socket.- Parameters:
host- the hostport- the portlocalAddr- the local addrlocalPort- the local portnum- the num- Throws:
UnknownHostException- the unknown host exceptionIOException- Signals that an I/O exception has occurred.
-
PTCPSocket
public PTCPSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int num) throws UnknownHostException, IOException Instantiates a new PTCP socket.- Parameters:
address- the addressport- the portlocalAddr- the local addrlocalPort- the local portnum- the num- Throws:
UnknownHostException- the unknown host exceptionIOException- Signals that an I/O exception has occurred.
-
-
Method Details
-
getInetAddress
Returns the address to which the socket is connected.- Overrides:
getInetAddressin classSocket
-
getInputStream
Returns an input stream for this socket.- Overrides:
getInputStreamin classSocket- Throws:
IOException
-
setKeepAlive
Enable/disable SO_KEEPALIVE.- Overrides:
setKeepAlivein classSocket- Throws:
SocketException
-
getKeepAlive
Tests if SO_KEEPALIVE is enabled.- Overrides:
getKeepAlivein classSocket- Throws:
SocketException
-
getLocalAddress
Gets the local address to which the socket is bound.- Overrides:
getLocalAddressin classSocket
-
getLocalPort
public int getLocalPort()Returns the local port to which this socket is bound.- Overrides:
getLocalPortin classSocket
-
getOutputStream
Returns an output stream for this socket.- Overrides:
getOutputStreamin classSocket- Throws:
IOException
-
getPort
-
setReceiveBufferSize
Sets the SO_RCVBUF option to the specified value for this Socket. The SO_RCVBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers. Increasing buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. For UDP, this sets the maximum size of a packet that may be sent on this Socket. Because SO_RCVBUF is a hint, applications that want to verify what size the buffers were set to should call getReceiveBufferSize().- Overrides:
setReceiveBufferSizein classSocket- Throws:
SocketException
-
getReceiveBufferSize
Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.- Overrides:
getReceiveBufferSizein classSocket- Throws:
SocketException
-
setSendBufferSize
Sets the SO_SNDBUF option to the specified value for this Socket. The SO_SNDBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers. Increasing buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. For UDP, this sets the maximum size of a packet that may be sent on this Socket. Because SO_SNDBUF is a hint, applications that want to verify what size the buffers were set to should call getSendBufferSize(). Parameters:- Overrides:
setSendBufferSizein classSocket- Throws:
SocketException
-
getSendBufferSize
Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.- Overrides:
getSendBufferSizein classSocket- Throws:
SocketException
-
setSoLinger
Enable/disable SO_LINGER with the specified linger time in seconds. The maximum timeout value is platform specific. The setting only affects socket close.- Overrides:
setSoLingerin classSocket- Throws:
SocketException
-
getSoLinger
Returns setting for SO_LINGER. -1 returns implies that the option is disabled. The setting only affects socket close.- Overrides:
getSoLingerin classSocket- Throws:
SocketException
-
setSoTimeout
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time. If the timeout expires, a java.io.InterruptedIOException is raised, though the Socket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.- Overrides:
setSoTimeoutin classSocket- Throws:
SocketException
-
getSoTimeout
Returns setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).- Overrides:
getSoTimeoutin classSocket- Throws:
SocketException
-
getTcpNoDelay
Tests if TCP_NODELAY is enabled.- Overrides:
getTcpNoDelayin classSocket- Throws:
SocketException
-
setTcpNoDelay
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).- Overrides:
setTcpNoDelayin classSocket- Throws:
SocketException
-
addSocket
-
shutdownInput
Places the input stream for this socket at "end of stream". Any data sent to the input stream side of the socket is acknowledged and then silently discarded. If you read from a socket input stream after invoking shutdownInput() on the socket, the stream will return EOF.- Overrides:
shutdownInputin classSocket- Throws:
IOException
-
shutdownOutput
Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.- Overrides:
shutdownOutputin classSocket- Throws:
IOException
-
toString
-
isConnected
public boolean isConnected()Returns the connection state of the socket.- Overrides:
isConnectedin classSocket
-
close
Close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSocket- Throws:
IOException
-