Java 类com.badlogic.gdx.net.Socket 实例源码

项目:Cubes_2    文件:ServerSocketMonitor.java   
@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();
}
项目:libgdxcn    文件:NetJavaSocketImpl.java   
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);
    }
}
项目:LibGDXServer    文件:ClientSocket.java   
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);
    }
}
项目:Cubes_2    文件:SocketMonitor.java   
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();
}
项目:Cubes_2    文件:ClientNetworking.java   
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;
    }
}
项目:Cubes    文件:SocketMonitor.java   
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();
}
项目:Cubes    文件:ClientNetworking.java   
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;
  }
}
项目:Cubes    文件:ServerSocketMonitor.java   
@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();
}
项目:libgdxcn    文件:NetJavaServerSocketImpl.java   
@Override
public Socket accept (SocketHints hints) {
    try {
        return new NetJavaSocketImpl(server.accept(), hints);
    } catch (Exception e) {
        throw new GdxRuntimeException("Error accepting socket.", e);
    }
}
项目:LibGDXServer    文件:ServerApplicationSocket.java   
@Override
public Socket accept(SocketHints hints) {
    try {
        return new ClientSocket(server.accept(), hints);
    } catch (Exception e) {
        throw new GdxRuntimeException("Error accepting socket.", e);
    }
}
项目:Cubes_2    文件:SocketMonitor.java   
public Socket getSocket() {
  return socket;
}
项目:Cubes_2    文件:ServerNetworking.java   
protected void accepted(Socket socket) {
    synchronized (sockets) {
        sockets.add(new SocketMonitor(socket, this, Side.Server));
        Log.info("Successfully connected to " + socket.getRemoteAddress());
    }
}
项目:Cubes    文件:SocketMonitor.java   
public Socket getSocket() {
  return socket;
}
项目:Cubes    文件:ServerNetworking.java   
protected synchronized void accepted(Socket socket) {
  sockets.add(new SocketMonitor(socket, this, Side.Server));
  Log.info("Successfully connected to " + socket.getRemoteAddress());
}
项目:JavityEngine    文件:JavityNet.java   
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) {
    return nativeNet.newClientSocket(protocol, host, port, hints);
}
项目:gdx-backend-jglfw    文件:JglfwNet.java   
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:gdx-lml    文件:ExtendedNet.java   
@Override
public Socket newClientSocket(final Protocol protocol, final String host, final int port, final SocketHints hints) {
    return net.newClientSocket(protocol, host, port, hints);
}
项目:libgdxcn    文件:NetJavaSocketImpl.java   
public NetJavaSocketImpl (java.net.Socket socket, SocketHints hints) {
    this.socket = socket;
    applyHints(hints);
}
项目:libgdxcn    文件:JglfwNet.java   
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:libgdxcn    文件:GwtNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    throw new UnsupportedOperationException("Not implemented");
}
项目:libgdxcn    文件:HeadlessNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:libgdxcn    文件:IOSNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:libgdxcn    文件:LwjglNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:libgdxcn    文件:AndroidNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:TinyVoxel    文件:GwtNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    throw new UnsupportedOperationException("Not implemented");
}
项目:LibGDXServer    文件:ClientSocket.java   
public ClientSocket(java.net.Socket socket, SocketHints hints) {
    this.socket = socket;
    applyHints(hints);
}
项目:LibGDXServer    文件:ServerNet.java   
@Override
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) {
    return new ClientSocket(protocol, host, port, hints);
}
项目:mini2Dx    文件:IOSMini2DxNet.java   
@Override
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
    return new NetJavaSocketImpl(protocol, host, port, hints);
}
项目:libgdxcn    文件:Net.java   
/** 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);