Created
June 29, 2015 08:59
-
-
Save frankbenoit/a168ee30eb831996b149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nbt; | |
import java.net.InetSocketAddress; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
import java.nio.channels.ServerSocketChannel; | |
import java.nio.channels.SocketChannel; | |
class Sender extends Thread { | |
public static void main(String[] args) throws Exception { | |
ServerSocketChannel ssc = ServerSocketChannel.open(); | |
ssc.bind(new InetSocketAddress(15000)); | |
ssc.configureBlocking(true); | |
SocketChannel ch = ssc.accept(); | |
System.out.println("connection accepted"); | |
// needed to trigger error | |
ch.socket().setTcpNoDelay(true); | |
ch.configureBlocking(true); | |
ByteBuffer buf = ByteBuffer.allocate(90); | |
buf.order(ByteOrder.BIG_ENDIAN); | |
int v = 1; | |
while( true ) { | |
buf.clear(); | |
buf.putInt( v ); | |
buf.position(0); | |
buf.limit(buf.capacity()); | |
while( buf.hasRemaining() ) { | |
ch.write(buf); | |
} | |
Thread.sleep(2); | |
v++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment