Package java.net

Examples of java.net.Socket$SocketInputStream


  public void header() throws IOException {
    try {
      URL url = new URL(getFile());
      String pwd = "";
      int port = url.getPort();
      socket = new Socket(url.getHost(), port == -1 ? url
          .getDefaultPort() : port);
      socket.setSoTimeout(((FtpService) connection.element).timeout);
      ps = new PrintStream(socket.getOutputStream());
      r = new BufferedReader(new InputStreamReader(socket
          .getInputStream()));
      receive();
      String user = "USER";
      String pass = "PASS";
      String userinfo = url.getUserInfo();
      if (userinfo == null) {
        user += " anonymous";
        pass += " yourname@yourcompany.com";
      } else {
        StringTokenizer st = new StringTokenizer(url.getUserInfo(), ":");
        user += " " + st.nextToken();
        pwd = st.nextToken();
        pass += " " + pwd;
      }
      send(user);
      if (result.startsWith("530 ")) {
        super.header();
        code = ServerStream.UNAUTHORIZED;
        return;
      }
      send(pass);
      if (result.startsWith("530 ") || result.startsWith("503 ")) {
        super.header();
        code = ServerStream.UNAUTHORIZED;
        return;
      }
      send("TYPE I");
      send("PASV");
      StringTokenizer st = new StringTokenizer(result.substring(result
          .indexOf('(') + 1, result.indexOf(')')), ",");
      socket2 = new Socket(st.nextToken() + '.' + st.nextToken() + '.'
          + st.nextToken() + '.' + st.nextToken(), Integer.valueOf(
          st.nextToken()).intValue()
          * 256 + Integer.parseInt(st.nextToken()));
      socket2.setSoTimeout(((FtpService) connection.element).timeout);
      out = new BufferedOutputStream(socket2.getOutputStream());
View Full Code Here


            this.sync = sync;
        }

        public void run() {
            try {
                socketWrapper.setSocket(new Socket(socketWrapper.getServer(), socketWrapper.getPort()));
                if (!socketWrapper.isValid()) {
                    socketWrapper.getSocket().close();
                    socketWrapper.setSocket(null);
                }
            } catch (IOException e) {
View Full Code Here

        final AtomicInteger counter = new AtomicInteger(count);
        Task serverThread = new Task() {
            public void call() {
                while (!stop) {
                    try {
                        Socket socket = serverSocket.accept();
                        // System.out.println("opened " + counter);
                        socket.close();
                    } catch (Exception e) {
                        // ignore
                    }
                }
                // System.out.println("stopped ");
View Full Code Here

        }

        public void run() {
            try {
                while (!isInterrupted() && counter.decrementAndGet() > 0) {
                    Socket socket = NetUtils.createLoopbackSocket(PORT, ssl);
                    try {
                        socket.close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
            } catch (Exception e) {
View Full Code Here

   */
  public boolean isSocketInUse() {
    if (!isRunning()) {
      // no instance of myself is running - check socket
      try {
        Socket socket = new Socket();
        int port = WGADesignerPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.TOMCAT_SERVER_PORT);
        socket.connect(new InetSocketAddress("127.0.0.1", port), 1000);
        socket.close();
        return true;
      } catch (IOException e) {
      }
    }
    return false;
View Full Code Here

          Element serverElement = (Element) doc.selectSingleNode("/Server");
          String serverPort = serverElement.attributeValue("port", "8005");
          String shutdownCommand = serverElement.attributeValue("shutdown", "SHUTDOWN");
         
          // send shutdown command to specified port
          Socket socket = new Socket();
          socket.connect(new InetSocketAddress("127.0.0.1", Integer.parseInt(serverPort)), 1000);
          socket.setSoTimeout(5000);
                  OutputStream stream = socket.getOutputStream();
                  for (int i = 0; i < shutdownCommand.length(); i++) {
                      stream.write(shutdownCommand.charAt(i));
                  }
                  stream.flush();
                  stream.close();
                  socket.close();

          monitor.worked(1);
         
          monitor.setTaskName("Waiting for wga shutdown ...");
          // wait for tomcat shutdown
View Full Code Here

    for(int j=0; j<i; j++){ if(foo[j]!=bar[j]) return false; }
    //try{while(true){i--; if(foo[i]!=bar[i])return false;}}catch(Exception e){}
    return true;
  }
  static Socket createSocket(String host, int port, int timeout) throws JSchException{
    Socket socket=null;
    if(timeout==0){
      try{
        socket=new Socket(host, port);
        return socket;
      }
      catch(Exception e){
        String message=e.toString();
        if(e instanceof Throwable)
          throw new JSchException(message, (Throwable)e);
        throw new JSchException(message);
      }
    }
    final String _host=host;
    final int _port=port;
    final Socket[] sockp=new Socket[1];
    final Exception[] ee=new Exception[1];
    String message="";
    Thread tmp=new Thread(new Runnable(){
        public void run(){
          sockp[0]=null;
          try{
            sockp[0]=new Socket(_host, _port);
          }
          catch(Exception e){
            ee[0]=e;
            if(sockp[0]!=null && sockp[0].isConnected()){
              try{
View Full Code Here

  }

  @Override
  public ObjectChannel createObjectChannel(SocketAddress address, boolean ssl) throws IOException,
      CommunicationException {
    final Socket socket;
    if (ssl) {
      if (this.sslSocketFactory == null) {
        try {
          sslSocketFactory = SocketUtil.getSSLSocketFactory(props);
        } catch (GeneralSecurityException e) {
          throw new CommunicationException(e);
        }
      }
      socket = sslSocketFactory.getSocket();
    } else {
      socket = new Socket();
    }
    if (receiveBufferSize > 0) {
      socket.setReceiveBufferSize(receiveBufferSize);
    }
    if (sendBufferSize > 0) {
      socket.setSendBufferSize(sendBufferSize);
    }
      socket.setTcpNoDelay(!conserveBandwidth); // enable Nagle's algorithm to conserve bandwidth
      socket.connect(address);
      socket.setSoTimeout(soTimeout);
      return new OioObjectChannel(socket);
  }
View Full Code Here

   */
  Socket createTunnelSocket(InetAddress host, int port,
                            InetAddress proxy, int proxyport) throws IOException {
    // Set up a socket to do tunneling through the proxy.
    // Start it off as a regular socket, then layer SSL over the top of it.
    Socket tunnel = new Socket(proxy, proxyport);
    doTunnelHandshake(tunnel, host, port);

    // Ok, let's overlay the tunnel socket with SSL.
    SSLSocket socket =
      (SSLSocket) getSocketFactory().createSocket(tunnel,host.getHostName(), port, true);
View Full Code Here

          reconnect();
          ((HttpConnection) connection).socket.close();
        }
        ((HttpConnection) connection).authority = url.getAuthority();
        int i = url.getPort();
        ((HttpConnection) connection).socket = new Socket(
            url.getHost(), i == -1 ? url.getDefaultPort() : i);
        ((HttpConnection) connection).socket
            .setSoTimeout(method.equalsIgnoreCase(ClientStream.GET)
                || method.equalsIgnoreCase(ClientStream.HEAD) ? ((HttpService) connection.element).timeoutShort
                : ((HttpService) connection.element).timeout);
View Full Code Here

TOP

Related Classes of java.net.Socket$SocketInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.