// we need to register our custom packet first
NetworkConfig.registerPacket((short) 1, AllFieldTypePacket.class);
NetworkConfig.DEBUG = true;
try {
BaseServer bsServer = new TCPServer(port); // create the server
System.out.println("Waiting for clients...");
// network loop
while (true) {
bsServer.update(100); // the main work
// iterate all received packets
BaseClient[] clients = bsServer.getReceivedPacketClients();
for (int i = 0; i < clients.length; i++) {
NetworkPacket[] packets = clients[i].getReceivedPackets();
// simply send back message OK
clients[i]