import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import com.jme3.network.kernel.*;
*/
public class SelectorKernel extends AbstractKernel
{
+ static Logger log = Logger.getLogger(SelectorKernel.class.getName());
+
private InetSocketAddress address;
private SelectorThread thread;
this( new InetSocketAddress(port) );
}
- public SelectorKernel( InetSocketAddress address )
+ public SelectorKernel( InetSocketAddress address )
{
- this.address = address;
+ this.address = address;
}
protected SelectorThread createSelectorThread()
// Register the server socket channel, indicating an interest in
// accepting new connections
serverChannel.register(selector, SelectionKey.OP_ACCEPT);
+
+ log.log( Level.INFO, "Hosting TCP connection:{0}.", address );
}
public void close() throws IOException, InterruptedException
// Setup the connection to be non-blocking
SocketChannel remoteChan = serverChan.accept();
remoteChan.configureBlocking(false);
-
+
// And disable Nagle's buffering algorithm... we want
- // data to go when we put it there.
+ // data to go when we put it there.
Socket sock = remoteChan.socket();
sock.setTcpNoDelay(true);
public void run()
{
+ log.log( Level.INFO, "Kernel started for connection:{0}.", address );
+
// An atomic is safest and costs almost nothing
while( go.get() ) {
// Setup any queued option changes
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import com.jme3.network.kernel.*;
*/
public class UdpKernel extends AbstractKernel
{
+ static Logger log = Logger.getLogger(UdpKernel.class.getName());
+
private InetSocketAddress address;
private HostThread thread;
- // The nature of UDP means that even through a firewall,
+ // The nature of UDP means that even through a firewall,
// a user would have to have a unique address+port since UDP
// can't really be NAT'ed.
private Map<SocketAddress,UdpEndpoint> socketEndpoints = new ConcurrentHashMap<SocketAddress,UdpEndpoint>();
public void connect() throws IOException
{
socket = new DatagramSocket( address );
+ log.log( Level.INFO, "Hosting UDP connection:{0}.", address );
}
public void close() throws IOException, InterruptedException
public void run()
{
+ log.log( Level.INFO, "Kernel started for connection:{0}.", address );
+
// An atomic is safest and costs almost nothing
while( go.get() ) {
try {