当前位置: 首页>>代码示例>>Java>>正文


Java Socket类代码示例

本文整理汇总了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();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:19,代码来源:ServerSocketMonitor.java

示例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);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:NetJavaSocketImpl.java

示例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);
	}
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:18,代码来源:ClientSocket.java

示例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();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:SocketMonitor.java

示例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;
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:14,代码来源:ClientNetworking.java

示例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;
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:14,代码来源:ClientNetworking.java

示例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();
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:14,代码来源:ServerSocketMonitor.java

示例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);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:9,代码来源:NetJavaServerSocketImpl.java

示例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);
	}
}
 
开发者ID:Olloth,项目名称:LibGDXServer,代码行数:9,代码来源:ServerApplicationSocket.java

示例10: getSocket

import com.badlogic.gdx.net.Socket; //导入依赖的package包/类
public Socket getSocket() {
  return socket;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:4,代码来源:SocketMonitor.java

示例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());
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:7,代码来源:ServerNetworking.java

示例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());
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:5,代码来源:ServerNetworking.java

示例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);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:4,代码来源:JavityNet.java

示例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);
}
 
开发者ID:Arcnor,项目名称:gdx-backend-jglfw,代码行数:4,代码来源:JglfwNet.java

示例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);
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:5,代码来源:ExtendedNet.java


注:本文中的com.badlogic.gdx.net.Socket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。