private synchronized void createDefaultEndpoint() { if (default_endpoint != null) return; default_endpoint = new CoapEndpoint(); try { default_endpoint.start(); LOGGER.log(Level.INFO, "Created implicit default endpoint {0}", default_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not create default endpoint", e); } }
private synchronized void createDefaultEndpoint() { if (default_endpoint != null) return; default_endpoint = new CoapEndpoint(); try { default_endpoint.start(); LOGGER.log(Level.INFO, "Created implicit default endpoint " + default_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not create default endpoint", e); } }
/** * Sets the endpoint this client is supposed to use. * * @param endpoint the endpoint * @return the CoAP client */ public CoapClient setEndpoint(Endpoint endpoint) { this.endpoint = endpoint; if (!endpoint.isStarted()) { try { endpoint.start(); LOGGER.log(Level.INFO, "Started set client endpoint {0}", endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not set and start client endpoint", e); } } return this; }
/** * Sets the endpoint this client is supposed to use. * * @param endpoint the endpoint * @return the CoAP client */ public CoapClient setEndpoint(Endpoint endpoint) { this.endpoint = endpoint; if (!endpoint.isStarted()) { try { endpoint.start(); LOGGER.log(Level.INFO, "Started set client endpoint " + endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not set and start client endpoint", e); } } return this; }
/** * Configures a new default secure endpoint. Any old default endpoint is destroyed. * @param endpoint the new default endpoint */ public void setDefaultSecureEndpoint(Endpoint endpoint) { if (this.default_secure_endpoint!=null) { this.default_secure_endpoint.destroy(); } this.default_secure_endpoint = endpoint; if (!this.default_secure_endpoint.isStarted()) { try { default_secure_endpoint.start(); LOGGER.log(Level.INFO, "Started new default secure endpoint " + default_secure_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default secure endpoint", e); } } }
/** * Configures a new default endpoint. Any old default endpoint is destroyed. * @param endpoint the new default endpoint */ public void setDefaultEndpoint(Endpoint endpoint) { if (this.default_endpoint!=null) { this.default_endpoint.destroy(); } LOGGER.config(endpoint.getAddress()+" becomes default endpoint"); this.default_endpoint = endpoint; if (!this.default_endpoint.isStarted()) { try { default_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default endpoint", e); } } }
/** * Configures a new default endpoint. Any old default endpoint is destroyed. * * @param endpoint * the new default endpoint */ public synchronized void setDefaultEndpoint(Endpoint endpoint) { if (this.default_endpoint != null) { this.default_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes default endpoint", endpoint.getAddress()); this.default_endpoint = endpoint; if (!this.default_endpoint.isStarted()) { try { default_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default endpoint", e); } } }
/** * Configures a new default secure endpoint. Any old default endpoint is * destroyed. * * @param endpoint * the new default endpoint */ public synchronized void setDefaultSecureEndpoint(Endpoint endpoint) { if (this.default_secure_endpoint != null) { this.default_secure_endpoint.destroy(); } this.default_secure_endpoint = endpoint; if (!this.default_secure_endpoint.isStarted()) { try { default_secure_endpoint.start(); LOGGER.log(Level.INFO, "Started new default secure endpoint {0}", default_secure_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default secure endpoint", e); } } }
/** * Configures a new secure tcp endpoint to use by default. Any old tcp * endpoint is destroyed. * * @param endpoint * the new default secure tcp endpoint. */ public synchronized void setTcpEndpoint(Endpoint endpoint) { if (this.default_tcp_endpoint != null) { this.default_tcp_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes tcp endpoint", endpoint.getAddress()); this.default_tcp_endpoint = endpoint; if (!this.default_tcp_endpoint.isStarted()) { try { default_tcp_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new tcp endpoint", e); } } }
/** * Configures a new secure tcp endpoint to use by default. Any old tcp * endpoint is destroyed. * * @param endpoint * the new default secure tcp endpoint. */ public synchronized void setSecureTcpEndpoint(Endpoint endpoint) { if (this.default_secure_tpc_endpoint != null) { this.default_secure_tpc_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes secure tcp endpoint", endpoint.getAddress()); this.default_secure_tpc_endpoint = endpoint; if (!this.default_secure_tpc_endpoint.isStarted()) { try { default_secure_tpc_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new secure tcp endpoint", e); } } }
for (Endpoint ep:endpoints) { try { ep.start();
for (Endpoint ep : endpoints) { try { ep.start();
private synchronized void createTcpEndpoint() { if (default_tcp_endpoint != null) return; NetworkConfig config = NetworkConfig.getStandard(); TcpClientConnector connector = new TcpClientConnector(config.getInt(NetworkConfig.Keys.TCP_WORKER_THREADS), config.getInt(NetworkConfig.Keys.TCP_CONNECT_TIMEOUT), config.getInt(NetworkConfig.Keys.TCP_CONNECTION_IDLE_TIMEOUT)); default_tcp_endpoint = new CoapEndpoint(connector, config); try { default_tcp_endpoint.start(); LOGGER.log(Level.INFO, "Created implicit tcp endpoint {0}", default_tcp_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not create tcp endpoint", e); } }
private synchronized void createSecureTcpEndpoint() { if (default_secure_tpc_endpoint != null) return; NetworkConfig config = NetworkConfig.getStandard(); TlsClientConnector connector = new TlsClientConnector(config.getInt(NetworkConfig.Keys.TCP_WORKER_THREADS), config.getInt(NetworkConfig.Keys.TCP_CONNECT_TIMEOUT), config.getInt(NetworkConfig.Keys.TCP_CONNECTION_IDLE_TIMEOUT)); default_secure_tpc_endpoint = new CoapEndpoint(connector, config); try { default_secure_tpc_endpoint.start(); LOGGER.log(Level.INFO, "Created implicit secure tcp endpoint {0}", default_secure_tpc_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not create secure tcp endpoint", e); } }
@Before public void createClient() throws IOException { clientEndpoint = new CoapEndpoint(config); clientEndpoint.start(); }
dtlsEndpoint.start(); EndpointManager.getEndpointManager().setDefaultSecureEndpoint(dtlsEndpoint);
@Before public void setupEndpoints() throws Exception { client = new CoapEndpoint(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), config); client.addInterceptor(clientInterceptor); client.start(); System.out.println("Client binds to port " + client.getAddress().getPort()); server = createLockstepEndpoint(client.getAddress()); }
@Before public void setupEndpoints() throws Exception { //exchangeStore = new InMemoryMessageExchangeStore(CONFIG, new InMemoryRandomTokenProvider(CONFIG)); // bind to loopback address using an ephemeral port // CoapEndpoint udpEndpoint = new CoapEndpoint(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), CONFIG, exchangeStore); client = new CoapEndpoint(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), CONFIG); client.addInterceptor(clientInterceptor); client.addInterceptor(new MessageTracer()); client.start(); System.out.println("Client binds to port " + client.getAddress().getPort()); server = createLockstepEndpoint(client.getAddress()); }
@Before public void setupServer() throws Exception { System.out.println(System.lineSeparator() + "Start " + getClass().getSimpleName()); NetworkConfig config = network.createTestConfig() .setInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE, 128) .setInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE, 128) .setInt(NetworkConfig.Keys.ACK_TIMEOUT, 200) // client retransmits after 200 ms .setInt(NetworkConfig.Keys.ACK_RANDOM_FACTOR, 1); client = new CoapEndpoint(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), config); client.addInterceptor(new MessageTracer()); client.start(); clientPort = client.getAddress().getPort(); server = createLockstepEndpoint(client.getAddress()); System.out.println("Client binds to port " + clientPort); }
clientEndpoint.start();