Can any one help me translate this Java code to C. I have tried so many different ways but with no success. I have the problem in the buffer part I don't know how to store the data and then send it using a C socket.
SocketChannel socketChannel = SocketChannel.open(); socketChannel.connect(new InetSocketAddress("127.0.0.1", 6633)); ByteBuffer buf = ByteBuffer.allocate(48); buf.clear(); byte version = 0x01; short length = 8; byte type = 0; buf.put(version); buf.put(type); buf.putShort(length); buf.putInt(12356); buf.flip(); socketChannel.write(buf); Thanks.