public NetJavaServerSocketImpl (Protocol protocol, int port, ServerSocketHints hints) { this.protocol = protocol; // create the server socket try { // initialize server = new java.net.ServerSocket(); if (hints != null) { server.setPerformancePreferences(hints.performancePrefConnectionTime, hints.performancePrefLatency, hints.performancePrefBandwidth); server.setReuseAddress(hints.reuseAddress); server.setSoTimeout(hints.acceptTimeout); server.setReceiveBufferSize(hints.receiveBufferSize); } // and bind the server... InetSocketAddress address = new InetSocketAddress(port); if (hints != null) { server.bind(address, hints.backlog); } else { server.bind(address); } } catch (Exception e) { throw new GdxRuntimeException("Cannot create a server socket at port " + port + ".", e); } }
public NetJavaSocketImpl (Protocol protocol, String host, int port, SocketHints hints) { try { // create the socket socket = new java.net.Socket(); applyHints(hints); // better to call BEFORE socket is connected! // and connect... InetSocketAddress address = new InetSocketAddress(host, port); if (hints != null) { socket.connect(address, hints.connectTimeout); } else { socket.connect(address); } } catch (Exception e) { throw new GdxRuntimeException("Error making a socket connection to " + host + ":" + port, e); } }
public static PingResult ping(ClientNetworkingParameter clientNP) { Log.debug("Pinging Host:" + clientNP.host + " Port:" + clientNP.port); Socket socket; try { socket = Gdx.net.newClientSocket(Protocol.TCP, clientNP.host, clientNP.port, socketHints); return ClientConnectionInitializer.ping(socket); } catch (Exception e) { PingResult pingResult = new PingResult(); pingResult.failure = true; pingResult.exception = e; return pingResult; } }
public static PingResult ping(ClientNetworkingParameter clientNetworkingParameter) { Log.debug("Pinging Host:" + clientNetworkingParameter.host + " Port:" + clientNetworkingParameter.port); Socket socket; try { socket = Gdx.net.newClientSocket(Protocol.TCP, clientNetworkingParameter.host, clientNetworkingParameter.port, socketHints); return ClientConnectionInitializer.ping(socket); } catch (Exception e) { PingResult pingResult = new PingResult(); pingResult.failure = true; pingResult.exception = e; return pingResult; } }
public ServerSocketMonitor(int port, ServerNetworking serverNetworking) { this.port = port; this.serverNetworking = serverNetworking; serverSocket = Gdx.net.newServerSocket(Protocol.TCP, port, Networking.serverSocketHints); running = new AtomicBoolean(true); }
@Override public ServerSocket newServerSocket (Protocol protocol, String hostname, int port, ServerSocketHints hints) { return new NetJavaServerSocketImpl(protocol, hostname, port, hints); }
public ServerSocket newServerSocket (Protocol protocol, int port, ServerSocketHints hints) { return new NetJavaServerSocketImpl(protocol, port, hints); }
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) { return new NetJavaSocketImpl(protocol, host, port, hints); }
/** @return the Protocol used by this socket */ public Protocol getProtocol ();
@Override public Protocol getProtocol () { return protocol; }
@Override public ServerSocket newServerSocket (Protocol protocol, int port, ServerSocketHints hints) { return new NetJavaServerSocketImpl(protocol, port, hints); }
@Override public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) { return new NetJavaSocketImpl(protocol, host, port, hints); }