Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class Main {
    public static void main(String[] argv) throws Exception {
        SocketChannel sChannel = SocketChannel.open();
        sChannel.configureBlocking(false);
        sChannel.connect(new InetSocketAddress("hostName", 12345));

        ByteBuffer buf = ByteBuffer.allocateDirect(1024);
        buf.put((byte) 0xFF);

        buf.flip();

        int numBytesWritten = sChannel.write(buf);
    }
}