logger.info("Starting BitTorrent tracker on {}...", getAnnounceUrl()); connection = new SocketConnection(new ContainerServer(myTrackerServiceContainer));
@BeforeClass public static void startServer() throws IOException { socketConnection = new SocketConnection(new Container() { public void handle(Request req, Response resp) { try { SocketAddress address = socketConnection.connect(new InetSocketAddress("localhost", 0));
@AfterClass public static void stopServer() throws IOException { if (null != socketConnection) { socketConnection.close(); } }
private class ActivationTask extends AsyncTask<String, String, String> { @Override protected String doInBackground(String... params) { SocketConnection connection = new SocketConnection(); String token = "getActivation|" + params[0] + "|"; return connection.EstablishConnection(token); } @Override protected void onPreExecute() { super.onPreExecute(); progressDialog.show(); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); progressDialog.dismiss(); if (s != null) { Log.e("RESULT" , s); } } }
... SocketConnection client = (SocketConnection) Connector.open("socket://" + hostname + ":" + port); // set application-specific options on the socket. Call setSocketOption to set other options client.setSocketOption(DELAY, 0); client.setSocketOption(KEEPALIVE, 0); InputStream is = client.openInputStream(); OutputStream os = client.openOutputStream(); // send something to server os.write("some string".getBytes()); // read server response int c = 0; while((c = is.read()) != -1) { // do something with the response } // close streams and connection is.close(); os.close(); client.close(); ...
SocketConnection hc = (SocketConnection) Connector .open("socket://79.99.7.153:80"); DataOutputStream dout = new DataOutputStream(hc.openOutputStream()); DataInputStream din = new DataInputStream(hc.openInputStream()); String userPass = "login" + ":" + "password"; byte[] encoded = Base64OutputStream.encode(userPass.getBytes(), 0, bos.write(bs); din.close(); hc.close(); response = bos.toString();
SocketConnection connection = new SocketConnection(); String token; response = connection.EstablishConnection(token);
OutputStream out = connection.openOutputStream(); InputStream in = connection.openInputStream(); connection.close(); final_OP(new String(baos.toByteArray()) ); } catch (IOException ex) {
final SimpleTraceAnalyzer analyzer = new SimpleTraceAnalyzer(); final SocketProcessor server = serverProvider.get(); connection = new SocketConnection(server, analyzer);
@Override public int start(int port, SSLContext context, boolean authReq) throws IOException { DirectRouter router = new DirectRouter(this); RouterContainer routerContainer = new RouterContainer(this, router, webSocketThreads); ContainerSocketProcessor processor = new ContainerSocketProcessor(routerContainer, threadCount, selectThreads); socketConnection = new SocketConnection(authReq ? new AuthRequiredServer(processor) : processor); InetSocketAddress actualAddress = (InetSocketAddress) socketConnection.connect(new InetSocketAddress(port), context); return actualAddress.getPort(); }
@Override public void stop() throws IOException { socketConnection.close(); }
eg : SocketConnection connection = new SocketConnection(); String token = "message that you want to write on server"; String response = connecation.EstablishConnection(token);
SocketConnection ssl = new SocketConnection(secure); InetSocketAddress address = new InetSocketAddress( port ); ssl.connect( address, sslc );
/** * Starts the server. * * @return Port used by server. * @throws IOException In case starting fails. */ public int start() throws IOException { handler = new ExpectationHandler(); connection = new SocketConnection(handler); final SocketAddress address = new InetSocketAddress(port); final InetSocketAddress connectedAddress = (InetSocketAddress) connection.connect(address); connectedPort = connectedAddress.getPort(); return connectedPort; }
@Test public void test503ResponseHandling() throws IOException { // https://bugzilla.redhat.com/show_bug.cgi?id=874983 HTTPMockContainer mockContainer = HTTPMockContainer.notOkResponse(Status.SERVICE_UNAVAILABLE); ContainerServer server = new ContainerServer(mockContainer); try (SocketConnection connection = new SocketConnection(server)) { InetSocketAddress address = (InetSocketAddress) connection .connect(new InetSocketAddress(0)); int port = address.getPort(); String command = "stats"; String url = "http://localhost:" + port + "/"; String project = "iok"; String version = "6.4"; // client.setErrors(true); client.processArgs(command, "--url", url, "--project", project, "--project-version", version, "--username", "admin", "--key", "abcdeabcdeabcdeabcdeabcdeabcde12"); server.stop(); Mockito.verify(mockAbortStrategy).abort(throwableCapture.capture()); assertThat("Client will display meaningful message for 503", throwableCapture.getValue().getMessage() .contains("unavailable")); } } }
public Adapter(Analyser handler, Scenario scenario) throws Exception { this.requestIds = Collections.synchronizedSet(new HashSet<String>()); this.server = new ContainerSocketProcessor(this, 10); this.connection = new SocketConnection(server); this.manager = new SecurityManager(); this.requests = new AtomicInteger(); this.failures = new AtomicInteger(); this.debug = scenario.debug(); this.handler = handler; this.scenario = scenario; }
public void start() { stopped = false; try { connection = new SocketConnection(this); } catch (Exception ex) { throw new RuntimeException("Couldnt create socket connection", ex); } initHttp(connection, httpPort); thMonitor = new Thread(new TaskMonitor()); thMonitor.start(); }
/** * Starts the server * @param port port of the server * @throws Exception */ public void start(int port) throws Exception { ServerLyzer.port = port; Container container = new ServerLyzer(config); Server server = new ContainerServer(container); this.connection = new SocketConnection(server); SocketAddress address = new InetSocketAddress(port); System.out.println("Starting server on port "+port); this.connection.connect(address); }
public void start(InetSocketAddress bindAddress, int poolSize) throws Exception { executor = Executors.newFixedThreadPool(poolSize); container = new HttpServer(); server = new ContainerServer(container); connection = new SocketConnection(server); SocketAddress address = bindAddress; connection.connect(address); }
/** * Starts proxy. * * @throws IOException In case starting fails. */ public void start() throws IOException { // Close existing connection if it exists. if (connection != null) { connection.close(); } proxy = new ProxyImplementation(); connection = new SocketConnection(proxy); final SocketAddress address = new InetSocketAddress(port); connection.connect(address); LOGGER.debug("Started on port: " + port); }