本文整理汇总了Java中com.badlogic.gdx.net.Socket类的典型用法代码示例。如果您正苦于以下问题:Java Socket类的具体用法?Java Socket怎么用?Java Socket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Socket类属于com.badlogic.gdx.net包,在下文中一共展示了Socket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
@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();
}
示例2: NetJavaSocketImpl
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
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);
}
}
示例3: ClientSocket
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
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);
}
}
示例4: SocketMonitor
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
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();
}
示例5: ping
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
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;
}
}
示例6: ping
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
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;
}
}
示例7: run
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
@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();
}
示例8: accept
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
@Override
public Socket accept (SocketHints hints) {
try {
return new NetJavaSocketImpl(server.accept(), hints);
} catch (Exception e) {
throw new GdxRuntimeException("Error accepting socket.", e);
}
}
示例9: accept
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
@Override
public Socket accept(SocketHints hints) {
try {
return new ClientSocket(server.accept(), hints);
} catch (Exception e) {
throw new GdxRuntimeException("Error accepting socket.", e);
}
}
示例10: getSocket
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
public Socket getSocket() {
return socket;
}
示例11: accepted
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
protected void accepted(Socket socket) {
synchronized (sockets) {
sockets.add(new SocketMonitor(socket, this, Side.Server));
Log.info("Successfully connected to " + socket.getRemoteAddress());
}
}
示例12: accepted
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
protected synchronized void accepted(Socket socket) {
sockets.add(new SocketMonitor(socket, this, Side.Server));
Log.info("Successfully connected to " + socket.getRemoteAddress());
}
示例13: newClientSocket
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints) {
return nativeNet.newClientSocket(protocol, host, port, hints);
}
示例14: newClientSocket
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
return new NetJavaSocketImpl(protocol, host, port, hints);
}
示例15: newClientSocket
import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
@Override
public Socket newClientSocket(final Protocol protocol, final String host, final int port, final SocketHints hints) {
return net.newClientSocket(protocol, host, port, hints);
}