Java Code Examples for java.net.BindException#printStackTrace()
The following examples show how to use
java.net.BindException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Setup.java From rdf-delta with Apache License 2.0 | 6 votes |
@Override public void restart() { server.stop(); //testPort = LibX.choosePort(); LocalServerConfig config = localServer.getConfig() ; LocalServer.release(localServer); localServer = LocalServer.create(config); resetDefaultHttpClient(); DeltaLink localLink = DeltaLinkLocal.connect(localServer); server = DeltaServer.create(testPort, localLink); try { server.start(); } catch (BindException e) { e.printStackTrace(); } relink(); }
Example 2
Source File: Setup.java From rdf-delta with Apache License 2.0 | 5 votes |
@Override public void beforeTest() { resetDefaultHttpClient(); testPort = WebLib.choosePort(); localServer = DeltaTestLib.createEmptyTestServerRocks(); DeltaLink localLink = DeltaLinkLocal.connect(localServer); server = DeltaServer.create(testPort, localLink); try { server.start(); } catch (BindException e) { e.printStackTrace(); } dlink = createLink(); }
Example 3
Source File: MockTcpSyslogServer.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@Override public void run() { System.out.println("TCP Server started"); this.thread = Thread.currentThread(); while (!shutdown) { try { final byte[] buffer = new byte[4096]; Socket socket = null; try { socket = socketServer.accept(); socket.setSoLinger(true, 0); final InputStream in = socket.getInputStream(); int i = in.read(buffer, 0, buffer.length); while (i != -1) { if (i < buffer.length) { final String line = new String(buffer, 0, i); messageList.add(line); i = in.read(buffer, 0, buffer.length); } else if (i == 0) { System.out.println("No data received"); } else { System.out.println("Message too long"); } } } catch (BindException be) { be.printStackTrace(); } finally { if (socket != null) { socket.close(); } } } catch (final Exception ex) { if (!shutdown) { System.out.println("Caught exception: " + ex.getMessage()); } } } System.out.println("TCP Server stopped"); }
Example 4
Source File: Driver.java From rdf-delta with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws InterruptedException { // Fix up fuseki config files. // DELTA_PORT => value. // This is a template that needs updating, // Server 1. Model model = RDFDataMgr.loadModel("fuseki-config.ttl"); // fuseki:name "%DS_NAME%" // delta:changes "%LOG_URL%" // delta:patchlog "%LOG_NAME%" // delta:zone "%ZONE_NAME%" update(model, "%DS_NAME%", DS_NAME); String LOG_URL = "http://localhost:"+DELTA_PORT+"/"; update(model, "%LOG_URL%", LOG_URL); update(model, "%LOG_NAME%", PATCH_LOG_NAME); String zone1 = ZONE1.toString(); String zone2 = ZONE2.toString(); update(model, "%ZONE_NAME%", zone1); // --- Reset state. if ( true ) { FileOps.ensureDir(DELTA_DIR); FileOps.clearAll(DELTA_DIR); FileOps.ensureDir(zone1); FileOps.clearAll(zone1); FileOps.ensureDir(zone2); FileOps.clearAll(zone2); } DeltaServer logServer = deltaServer(DELTA_PORT, DELTA_DIR); try { logServer.start(); } catch (BindException e) { e.printStackTrace(); System.exit(0); } // RDFDataMgr.write(System.out, model, Lang.TTL); // System.out.flush(); FusekiServer server1 = fuseki(F1_PORT, model); server1.start(); //FusekiServer server2 = fuseki2(); int numClients = 10; int clientLoops = 10; CountDownLatch cdl1 = new CountDownLatch(numClients); CountDownLatch cdl2 = new CountDownLatch(numClients); for (int i = 0 ; i < numClients ; i++ ) { client(clientLoops, cdl1, cdl2); } cdl2.await(); logServer.stop(); System.out.println("DONE"); System.exit(0); }
Example 5
Source File: SinglePointServer.java From mil-sym-java with Apache License 2.0 | 4 votes |
private void createHttpServer() { try { // A maximum backlog can be specified. This is the maximum number // of queued incoming connections to allow on the listening socket. // Queued connection above this limit may be rejected. // If set <=0, a system default value is used. _singlePointHandler = new SinglePointHandler(0); int backlog = _backLog; httpServer = HttpServer.create(new InetSocketAddress("127.0.0.1", portNumber), backlog); httpServer.createContext("/", _singlePointHandler); httpServer.createContext("/mil-sym-service/renderer/image/", new SinglePointHandler(RENDER_TYPE_IMAGE)); httpServer.createContext("/mil-sym-service/renderer/kml/", new SinglePointHandler(RENDER_TYPE_KML)); httpServer.createContext("/mil-sym-service/renderer/svg/", new SinglePointHandler(RENDER_TYPE_SVG)); httpServer.setExecutor(Executors.newCachedThreadPool()); } catch(BindException bexc){ String strTypicalPortInUseMessage = "Address already in use: bind"; if(bexc.getMessage().startsWith(strTypicalPortInUseMessage)) { System.out.println("Port " + String.valueOf(portNumber) + " already in use. Incrementing..."); } else { System.err.println(bexc.getMessage()); bexc.printStackTrace(); } portNumber++; //System.err.println(ErrorLogger.getStackTrace(bexc)); createHttpServer(); // throw(exc); } catch (IOException exc) { System.err.println(exc.getMessage()); System.err.println(ErrorLogger.getStackTrace(exc)); //portNumber++; //createHttpServer(); // throw(exc); } catch (Exception exc2) { System.err.println(exc2.getMessage()); System.err.println(ErrorLogger.getStackTrace(exc2)); } }
Example 6
Source File: MultiPointServer.java From mil-sym-java with Apache License 2.0 | 4 votes |
private void createHttpServer() { try { // A maximum backlog can be specified. This is the maximum number // of queued incoming connections to allow on the listening socket. // Queued connection above this limit may be rejected. // If set <=0, a system default value is used. int backlog = _backLog; httpServer = HttpServer.create(new InetSocketAddress("127.0.0.1", portNumber), backlog); HttpContext c3d = httpServer.createContext("/mil-sym-service/renderer/mp3d/", new MultiPointHandler(false)); HttpContext c2d = httpServer.createContext("/mil-sym-service/renderer/mp2d/", new MultiPointHandler(true)); //for parsing post parameters c3d.getFilters().add(new ParameterFilter()); c2d.getFilters().add(new ParameterFilter()); httpServer.setExecutor(Executors.newCachedThreadPool()); } catch(BindException bexc){ String strTypicalPortInUseMessage = "Address already in use: bind"; if(bexc.getMessage().startsWith(strTypicalPortInUseMessage)) { System.out.println("Port " + String.valueOf(portNumber) + " already in use. Incrementing..."); } else { System.err.println(bexc.getMessage()); bexc.printStackTrace(); } portNumber++; //System.err.println(ErrorLogger.getStackTrace(bexc)); createHttpServer(); // throw(exc); } catch (IOException exc) { System.err.println(exc.getMessage()); System.err.println(ErrorLogger.getStackTrace(exc)); //portNumber++; //createHttpServer(); // throw(exc); } catch (Exception exc2) { System.err.println(exc2.getMessage()); System.err.println(ErrorLogger.getStackTrace(exc2)); } }