Class PTCPSocket

java.lang.Object
java.net.Socket
ecmwf.common.transport.ptcp.psocket.PTCPSocket
All Implemented Interfaces:
Closeable, AutoCloseable

public class PTCPSocket extends Socket
The Class PTCPSocket.
  • Constructor Details

    • PTCPSocket

      public PTCPSocket(int num)
      Instantiates a new PTCP socket.
      Parameters:
      num - the num
    • PTCPSocket

      public PTCPSocket(String host, int port, int num) throws UnknownHostException, IOException
      Instantiates a new PTCP socket.
      Parameters:
      host - the host
      port - the port
      num - the num
      Throws:
      UnknownHostException - the unknown host exception
      IOException - Signals that an I/O exception has occurred.
    • PTCPSocket

      public PTCPSocket(InetAddress address, int port, int num) throws UnknownHostException, IOException
      Instantiates a new PTCP socket.
      Parameters:
      address - the address
      port - the port
      num - the num
      Throws:
      UnknownHostException - the unknown host exception
      IOException - 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 host
      port - the port
      localAddr - the local addr
      localPort - the local port
      num - the num
      Throws:
      UnknownHostException - the unknown host exception
      IOException - 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 address
      port - the port
      localAddr - the local addr
      localPort - the local port
      num - the num
      Throws:
      UnknownHostException - the unknown host exception
      IOException - Signals that an I/O exception has occurred.
  • Method Details

    • getInetAddress

      public InetAddress getInetAddress()
      Returns the address to which the socket is connected.
      Overrides:
      getInetAddress in class Socket
    • getInputStream

      public InputStream getInputStream() throws IOException
      Returns an input stream for this socket.
      Overrides:
      getInputStream in class Socket
      Throws:
      IOException
    • setKeepAlive

      public void setKeepAlive(boolean on) throws SocketException
      Enable/disable SO_KEEPALIVE.
      Overrides:
      setKeepAlive in class Socket
      Throws:
      SocketException
    • getKeepAlive

      public boolean getKeepAlive() throws SocketException
      Tests if SO_KEEPALIVE is enabled.
      Overrides:
      getKeepAlive in class Socket
      Throws:
      SocketException
    • getLocalAddress

      public InetAddress getLocalAddress()
      Gets the local address to which the socket is bound.
      Overrides:
      getLocalAddress in class Socket
    • getLocalPort

      public int getLocalPort()
      Returns the local port to which this socket is bound.
      Overrides:
      getLocalPort in class Socket
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Returns an output stream for this socket.
      Overrides:
      getOutputStream in class Socket
      Throws:
      IOException
    • getPort

      public int getPort()
      Returns the remote port to which this socket is connected.
      Overrides:
      getPort in class Socket
    • setReceiveBufferSize

      public void setReceiveBufferSize(int size) throws SocketException
      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:
      setReceiveBufferSize in class Socket
      Throws:
      SocketException
    • getReceiveBufferSize

      public int getReceiveBufferSize() throws SocketException
      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:
      getReceiveBufferSize in class Socket
      Throws:
      SocketException
    • setSendBufferSize

      public void setSendBufferSize(int size) throws SocketException
      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:
      setSendBufferSize in class Socket
      Throws:
      SocketException
    • getSendBufferSize

      public int getSendBufferSize() throws SocketException
      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:
      getSendBufferSize in class Socket
      Throws:
      SocketException
    • setSoLinger

      public void setSoLinger(boolean on, int linger) throws SocketException
      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:
      setSoLinger in class Socket
      Throws:
      SocketException
    • getSoLinger

      public int getSoLinger() throws SocketException
      Returns setting for SO_LINGER. -1 returns implies that the option is disabled. The setting only affects socket close.
      Overrides:
      getSoLinger in class Socket
      Throws:
      SocketException
    • setSoTimeout

      public void setSoTimeout(int timeout) throws SocketException
      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:
      setSoTimeout in class Socket
      Throws:
      SocketException
    • getSoTimeout

      public int getSoTimeout() throws SocketException
      Returns setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).
      Overrides:
      getSoTimeout in class Socket
      Throws:
      SocketException
    • getTcpNoDelay

      public boolean getTcpNoDelay() throws SocketException
      Tests if TCP_NODELAY is enabled.
      Overrides:
      getTcpNoDelay in class Socket
      Throws:
      SocketException
    • setTcpNoDelay

      public void setTcpNoDelay(boolean on) throws SocketException
      Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
      Overrides:
      setTcpNoDelay in class Socket
      Throws:
      SocketException
    • addSocket

      public void addSocket(Socket[] sockets, Socket commSock)
      Adds the socket.
      Parameters:
      sockets - the sockets
      commSock - the comm sock
    • shutdownInput

      public void shutdownInput() throws IOException
      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:
      shutdownInput in class Socket
      Throws:
      IOException
    • shutdownOutput

      public void shutdownOutput() throws IOException
      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:
      shutdownOutput in class Socket
      Throws:
      IOException
    • toString

      public String toString()
      Converts this socket to a String.
      Overrides:
      toString in class Socket
    • isConnected

      public boolean isConnected()
      Returns the connection state of the socket.
      Overrides:
      isConnected in class Socket
    • close

      public void close() throws IOException
      Close.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class Socket
      Throws:
      IOException