/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * * @param host The remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @throws SocketException If the socket timeout could not be set. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @throws IllegalArgumentException If an invalid local port number * is specified. ***/ @Override public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) { throw new IllegalArgumentException("Invalid port number " + localPort); } super.connect(host, port, localAddr, localPort); }
throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(hostname, port, localAddr, localPort);
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param host The remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @exception SocketException If the socket timeout could not be set. * @exception IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @exception IllegalArgumentException If an invalid local port number * is specified. ***/ public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(host, port, localAddr, localPort); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param hostname The name of the remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @exception SocketException If the socket timeout could not be set. * @exception IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @exception UnknownHostException If the hostname cannot be resolved. * @exception IllegalArgumentException If an invalid local port number * is specified. ***/ @Override public void connect(String hostname, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(hostname, port, localAddr, localPort); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param host The remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @exception SocketException If the socket timeout could not be set. * @exception IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @exception IllegalArgumentException If an invalid local port number * is specified. ***/ @Override public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(host, port, localAddr, localPort); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * <p> * @param hostname The name of the remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @exception SocketException If the socket timeout could not be set. * @exception IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @exception UnknownHostException If the hostname cannot be resolved. * @exception IllegalArgumentException If an invalid local port number * is specified. ***/ public void connect(String hostname, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(hostname, port, localAddr, localPort); }
try { if (!client.isConnected()) { client.connect(url);