Package java.net

Examples of java.net.ServerSocket


        this.timeout = timeout;
    }

    public ServerSocket createServerSocket(int port) throws IOException {
        if(timeout == 0) {
            return new ServerSocket(port, backlog, bindAddress);
        }
        return new TimeoutServerSocket(timeout, port, backlog, bindAddress);
    }
View Full Code Here


        }
       
      }else{
       
        try{
          ServerSocket ss;
         
          int  port = getPort();
         
          if ( _bind_ip != null ){
         
            current_bind_ip = _bind_ip;
           
            ss = new ServerSocketport, 1024, _bind_ip );

          }else if ( bind_ip == null ){
           
            ss = new ServerSocketport, 1024 );
           
          }else{
           
            current_bind_ip = bind_ip;
           
            ss = new ServerSocketport, 1024, bind_ip );
          }
         
          if ( port == 0 ){
           
            setPort( ss.getLocalPort());
          }
         
          ss.setReuseAddress(true);
         
          server_socket = ss;
         
          Thread accept_thread =
              new AEThread("TRTrackerServer:accept.loop")
View Full Code Here

  public static final int STATE_LISTENING = 1;

  public StartServer() {
    super("Start Server");
    try {
      socket = new ServerSocket(6880, 50, InetAddress.getByName("127.0.0.1")); //NOLAR: only bind to localhost
      state = STATE_LISTENING;
      Logger.getLogger("azureus2").info("StartServer: listening on 127.0.0.1:6880 for passed torrent info");
    } catch (Exception e) {
      state = STATE_FAULTY;
View Full Code Here

  public SocketServer(UI ui, int port, Set allowedHosts, UserManager userManager, int maxLoginAttempts) throws IOException
  {
    this.ui = ui;
    this.allowedHosts = allowedHosts;
    this.userManager = userManager;
    serverSocket = new ServerSocket(port);
    this.maxLoginAttempts = maxLoginAttempts;
  }
View Full Code Here

  protected static boolean
  startListener(
    final LoggerChannelListener  log )
  {
    try{
      final ServerSocket server_socket = new ServerSocket( port, 50, InetAddress.getByName("127.0.0.1"));
               
      log.messageLogged(
            LoggerChannel.LT_INFORMATION,
            "SingleInstanceHandler: listening on 127.0.0.1:" + port + " for passed arguments");
     
      Thread t =
        new Thread("Single Instance Handler")
        {
            public void
            run()
          {
                while ( true ){
                 
                  Socket socket      = null;
                  ObjectInputStream  ois  = null;
                 
                  try{
                    socket = server_socket.accept();
                   
                    String address = socket.getInetAddress().getHostAddress();
                   
                    if ( !( address.equals("localhost") || address.equals("127.0.0.1"))){
                     
View Full Code Here

            for (InetAddress address : InetAddress.getAllByName(localhost.getHostAddress())) {
                System.out.println("  " + address);
            }
            InetAddress address = InetAddress.getByName(localhost.getHostAddress());
            System.out.println("byName:" + address);
            ServerSocket serverSocket;
            try {
                serverSocket = new ServerSocket(0);
            } catch (Exception e) {
                e.printStackTrace();
                serverSocket = new ServerSocket(0);
            }
            System.out.println(serverSocket);
            int port = serverSocket.getLocalPort();
            final ServerSocket accept = serverSocket;
            Thread thread = new Thread() {
                public void run() {
                    try {
                        System.out.println("server accepting");
                        Socket s = accept.accept();
                        Thread.sleep(100);
                        System.out.println("server accepted:" + s);
                        System.out.println("server read:" + s.getInputStream().read());
                        Thread.sleep(200);
                        s.getOutputStream().write(234);
View Full Code Here

            break;
        case 'P':
            if ("PWD".equals(command)) {
                reply(257, StringUtils.quoteIdentifier(currentDir) + " directory");
            } else if ("PASV".equals(command)) {
                ServerSocket dataSocket = FtpServer.createDataSocket();
                data = new FtpData(server, control.getInetAddress(), dataSocket);
                data.start();
                int port = dataSocket.getLocalPort();
                reply(227, "Passive Mode (" + serverIpAddress + "," + (port >> 8) + "," + (port & 255) + ")");
            } else if ("PORT".equals(command)) {
                String[] list = StringUtils.arraySplit(param, ',', true);
                String host = list[0] + "." + list[1] + "." + list[2] + "." + list[3];
                int port = (Integer.parseInt(list[4]) << 8) | Integer.parseInt(list[5]);
View Full Code Here

                portClient = Integer.parseInt(args[++i]);
            } else if ("-server".equals(args[i])) {
                portServer = Integer.parseInt(args[++i]);
            }
        }
        ServerSocket listener = new ServerSocket(portClient);
        while (true) {
            Socket client = listener.accept();
            Socket server = new Socket("localhost", portServer);
            TcpRedirectThread c = new TcpRedirectThread(client, server, true);
            TcpRedirectThread s = new TcpRedirectThread(server, client, false);
            new Thread(c).start();
            new Thread(s).start();
View Full Code Here

      try {
        loop:
          while (running) {
            canStop = true;
            try {
              ServerSocket listen = tcpServer.getListen();
              if (listen != null) {
                socket = listen.accept();
                canStop = false;
              } else {
                break loop;
              }
            } catch (IOException exc) {
View Full Code Here

                       args + ',' + firstTime + ')');
    int port = Integer.parseInt(args);

    // Create the socket here in order to throw an exception
    // if the socket can't be created (even if firstTime is false).
    ServerSocket serverSocket = new ServerSocket(port);

    tcpServer = new HATcpServer(
      serverSocket,
      3,
      getDefault());
View Full Code Here

TOP

Related Classes of java.net.ServerSocket

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.