Package freenet.io.comm

Examples of freenet.io.comm.UdpSocketHandler


    int port = config.getPort();

    FreenetInetAddress bindto = config.getBindTo();

    UdpSocketHandler u = null;

    if(port > 65535) {
      throw new NodeInitException(NodeInitException.EXIT_IMPOSSIBLE_USM_PORT, "Impossible port number: "+port);
    } else if(port == -1) {
      // Pick a random port
      for(int i=0;i<200000;i++) {
        int portNo = 1024 + random.nextInt(65535-1024);
        try {
          u = new UdpSocketHandler(portNo, bindto.getAddress(), node, startupTime, getTitle(portNo), node.collector);
          port = u.getPortNumber();
          break;
        } catch (Exception e) {
          Logger.normal(this, "Could not use port: "+bindto+ ':' +portNo+": "+e, e);
          System.err.println("Could not use port: "+bindto+ ':' +portNo+": "+e);
          e.printStackTrace();
          continue;
        }
      }
      if(u == null)
        throw new NodeInitException(NodeInitException.EXIT_NO_AVAILABLE_UDP_PORTS, "Could not find an available UDP port number for FNP (none specified)");
    } else {
      try {
        u = new UdpSocketHandler(port, bindto.getAddress(), node, startupTime, getTitle(port), node.collector);
      } catch (Exception e) {
        Logger.error(this, "Caught "+e, e);
        System.err.println(e);
        e.printStackTrace();
        throw new NodeInitException(NodeInitException.EXIT_IMPOSSIBLE_USM_PORT, "Could not bind to port: "+port+" (node already running?)");
View Full Code Here

TOP

Related Classes of freenet.io.comm.UdpSocketHandler

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.