@Override public void run() { Side.setSide(Side.Server); boolean isRunning = running.get(); try { while (isRunning) { Socket accept = serverSocket.accept(Networking.socketHints); ServerConnectionInitializer.check(accept); isRunning = running.get(); } } catch (Exception e) { if (running.get()) Log.error(e); } dispose(); }
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 ClientSocket(Net.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 SocketMonitor(Socket socket, Networking networking, Side side) { this.socket = socket; this.networking = networking; this.side = side; this.remoteAddress = socket.getRemoteAddress(); running = new AtomicBoolean(true); socketInput = new SocketInput(this); socketOutput = new SocketOutput(this); socketInput.start("Socket Input: " + remoteAddress); socketOutput.start("Socket Output: " + remoteAddress); this.packetIDDatabase = new PacketIDDatabase(); }
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; } }
@Override public void run() { Side.setSide(Side.Server); while (running.get()) { try { Socket accept = serverSocket.accept(Networking.socketHints); ServerConnectionInitializer.check(accept); } catch (Exception e) { if (running.get()) Log.error(e); } } dispose(); }
@Override public Socket accept (SocketHints hints) { try { return new NetJavaSocketImpl(server.accept(), hints); } catch (Exception e) { throw new GdxRuntimeException("Error accepting socket.", e); } }
@Override public Socket accept(SocketHints hints) { try { return new ClientSocket(server.accept(), hints); } catch (Exception e) { throw new GdxRuntimeException("Error accepting socket.", e); } }
public Socket getSocket() { return socket; }
protected void accepted(Socket socket) { synchronized (sockets) { sockets.add(new SocketMonitor(socket, this, Side.Server)); Log.info("Successfully connected to " + socket.getRemoteAddress()); } }
protected synchronized void accepted(Socket socket) { sockets.add(new SocketMonitor(socket, this, Side.Server)); Log.info("Successfully connected to " + socket.getRemoteAddress()); }
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) { return nativeNet.newClientSocket(protocol, host, port, hints); }
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) { return new NetJavaSocketImpl(protocol, host, port, hints); }
@Override public Socket newClientSocket(final Protocol protocol, final String host, final int port, final SocketHints hints) { return net.newClientSocket(protocol, host, port, hints); }
public NetJavaSocketImpl (java.net.Socket socket, SocketHints hints) { this.socket = socket; applyHints(hints); }
@Override public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) { throw new UnsupportedOperationException("Not implemented"); }
@Override public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) { return new NetJavaSocketImpl(protocol, host, port, hints); }
public ClientSocket(java.net.Socket socket, SocketHints hints) { this.socket = socket; applyHints(hints); }
@Override public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) { return new ClientSocket(protocol, host, port, hints); }
/** Creates a new TCP client socket that connects to the given host and port. * * @param host the host address * @param port the port * @param hints additional {@link SocketHints} used to create the socket. Input null to use the default setting provided by the * system. * @return GdxRuntimeException in case the socket couldn't be opened */ public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints);