Package sun.net

Class NetworkClient

  • Direct Known Subclasses:
    HttpClient

    public class NetworkClient
    extends Object
    This is the base class for network clients.
    • Field Detail

      • DEFAULT_CONNECT_TIMEOUT

        public static final int DEFAULT_CONNECT_TIMEOUT
        See Also:
        Constant Field Values
      • serverSocket

        @Nullable
        protected Socket serverSocket
        Socket for communicating with server.
      • serverInput

        @Nullable
        public InputStream serverInput
        Buffered stream for reading replies from server.
      • defaultSoTimeout

        protected static int defaultSoTimeout
      • defaultConnectTimeout

        protected static int defaultConnectTimeout
      • readTimeout

        protected int readTimeout
      • connectTimeout

        protected int connectTimeout
      • encoding

        protected static String encoding
    • Constructor Detail

      • NetworkClient

        public NetworkClient​(String host,
                             int port)
                      throws IOException
        Create connection with host host on port port
        Throws:
        IOException
      • NetworkClient

        public NetworkClient()
    • Method Detail

      • createSocket

        protected Socket createSocket()
                               throws IOException
        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.
        Throws:
        IOException
      • closeServer

        public void closeServer()
                         throws IOException
        Close an open connection to the server.
        Throws:
        IOException
      • serverIsOpen

        public boolean serverIsOpen()
        Return server connection status
      • setConnectTimeout

        public void setConnectTimeout​(int timeout)
      • getConnectTimeout

        public int getConnectTimeout()
      • setReadTimeout

        public void setReadTimeout​(int timeout)
        Sets the read timeout. Note: Public URLConnection (and protocol specific implementations) protect against negative timeout values being set. This implementation, and protocol specific implementations, use -1 to represent the default read timeout. This method may be invoked with the default timeout value when the protocol handler is trying to reset the timeout after doing a potentially blocking internal operation, e.g. cleaning up unread response data, buffering error stream response data, etc
      • getReadTimeout

        public int getReadTimeout()