What I'm trying to do is: Writing client and server for sending a String via TCP with Java, so far no problem using Socket and Input-/Output-Streams.
But now I'm trying to add 3 numbers to the "Options" field in the tcp header . I can't find any helpful tutorials or something else on how to customize the header and how to read it.
Any suggestions?
You can't:
You can somewhat influence some of the TCP behavior by setting different socket options, though. But not manipulating TCP headers directly.
Not without utilizing external library like jNetPcap. jNetPcap does allow you to format and send your own packet.
jNetPcap Installation Guide (Eclipse)
jNetPcap Installation Guide (NetBeans)
A very rough sample code for formatting and sending packet. Rough it may be, but it shows you the possibilities to customize the packet.
Edit: Forgot to mention that jNetPcap is a Java wrapper for libpcap. They are meant to be utilized to read the packet in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With