Package java.net

Examples of java.net.ServerSocket


     */
     protected FTPDataSocket newActiveDataSocket(int port)
      throws IOException {
        
        // ensure server sock gets the timeout
       ServerSocket sock = listenOnAllInterfaces ?
               new ServerSocket(port) : new ServerSocket(port, 0, controlSock.getLocalAddress());
       log.debug("ListenOnAllInterfaces=" + listenOnAllInterfaces);
       sock.setSoTimeout(controlSock.getSoTimeout());
       FTPActiveDataSocket activeSock = new FTPActiveDataSocket(sock);
       activeSock.setLocalAddress(controlSock.getLocalAddress());
       return activeSock;
     }
View Full Code Here


                registered=true;
            }
   
            if(bindAddressString != null) {
                bindAddress=InetAddress.getByName(bindAddressString);
                srvSock=new ServerSocket(port, backlog, bindAddress);
            }
            else {
                srvSock=new ServerSocket(port, backlog);
            }      
   
            Runtime.getRuntime().addShutdownHook(new Thread() {
                public void run() {
                    GossipRouter.this.stop();
View Full Code Here

    try {
      if (isRunning()) return;

      if (port != 0) {
        dmon = new Daemon[NbDaemon];
        ServerSocket listen = createServerSocket();

        for (int i=0; i<NbDaemon; i++) {
          dmon[i] = new NetServerIn(getName() + '.' + i, listen, logmon);
        }
      } else {
View Full Code Here

        channel.configureBlocking(false);

        // Bind the server socket to the local host and port
        InetAddress host = InetAddress.getLocalHost();
        InetSocketAddress sockAddr = new InetSocketAddress(host, PORT);
        ServerSocket socket = channel.socket();
        //socket.setReuseAddress(true);
        socket.bind(sockAddr);

        // Register accepts on the server socket with the selector. This
        // step tells the selector that the socket wants to be put on the
        // ready list when accept operations occur.
        Selector selector = Selector.open();
View Full Code Here

   * @return    a server socket bound to the specified port.
   *
   * @exception IOException  for networking errors
   */
  ServerSocket createServerSocket(int port) throws IOException {
    ServerSocket serverSocket =
      serverSocketFactory.createServerSocket(port, backlog, inLocalAddr);
    ((SSLServerSocket) serverSocket).setNeedClientAuth(true);
    return serverSocket;
  }
View Full Code Here

            // start the actual server sockets and threads
            TcpServer[] servers = new TcpServer[ports.length];
            for (int i = 0; i < ports.length; i++) {
                try {
                    ServerSocket socket = new ServerSocket(ports[i]);
                    servers[i] = new TcpServer(socket, sdefs[i]);
                    Thread thread = new Thread(servers[i]);
                    thread.start();
                } catch (IOException e) {
                    System.err.println("Error opening socket on port " + ports[i] + " for service "
View Full Code Here

                // this method does not actually create the SSL socket, due to a JVM bug
                // (https://issues.apache.org/jira/browse/FTPSERVER-241).
                // Instead, it creates a regular
                // ServerSocket that will be wrapped as a SSL socket in createDataSocket()
                servSoc = new ServerSocket(passivePort, 0, address);
                LOG
                        .debug(
                                "SSL Passive data connection created on address \"{}\" and port {}",
                                address, passivePort);
            } else {
                LOG
                        .debug(
                                "Opening passive data connection on address \"{}\" and port {}",
                                address, passivePort);
                servSoc = new ServerSocket(passivePort, 0, address);
                LOG
                        .debug(
                                "Passive data connection created on address \"{}\" and port {}",
                                address, passivePort);
            }
View Full Code Here

   
    private static String classToStart = "org.gudy.azureus2.ui.swt.updater.snippets.Started";
   
    public static void main(String args[]) {
        try {
          ServerSocket server = new ServerSocket(6880, 50, InetAddress.getByName("127.0.0.1"));
          spawnStarted();
          server.close();
        } catch(Exception e) {
          Debug.printStackTrace( e );
        }
    }
View Full Code Here

        // socket bind.
        boolean ok = false;
        try {
            while(!ok) {
              try{
                ServerSocket server = new ServerSocket(6880, 50, InetAddress.getByName("127.0.0.1"));
                ok = true;
                server.close();
              } catch(Exception e) {
                Logger.log("Exception while trying to bind on port 6880 : " + e);
                Thread.sleep(1000);
              }
            }
View Full Code Here

    {
    try {
      // DON'T USE LOGGER HERE DUE TO COMMENTS BELOW - IF AZ ALREADY RUNNING THEN THE SERVERSOCKET
      // CALL WILL THROW AN EXCEPTION
     
      socket = new ServerSocket(6880, 50, InetAddress.getByName("127.0.0.1")); //NOLAR: only bind to localhost
       
        state = STATE_LISTENING;   
       
        if (Logger.isEnabled())
          Logger.log(new LogEvent(LOGID, "StartServer: listening on "
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.