0
votes

With TCP protocol, is it possible to bind to a port, listen for data. And handle TCP flags manually?

EDIT

A normal program could do socket(), bind(), then listen() and accept() connections. Then you can get data from the socket, not the TCP flags, e.g PSH + ACK

Here's what I want, when a TCP connection is not established yet, just any packet sent to a port of a server, I want to see the TCP flags it uses, e.g SYN, SYN + ACK

EDIT

Yes I know about pcap and packet socket, but I didn't meant to capture packets. I mean a server listens on a port and handle the TCP flags ..

1
Elaborate on what you mean handle "TCP Flags"?Noam Rathaus
Do you mean on a TCP socket? Or more generally you want to see more of TCP protocol in user space (in which case a raw IP socket would offer you that)?Joe
@nrathaus yes, even before connection is established (the 3 way handshake)daisy
@Joe yes on a TCP socket. Can you see my update please?daisy
You can use Pcap on Linux, and construct packets by yourself and capture the traffic using "pcap filters".Noam Rathaus

1 Answers

1
votes

No. The Linux kernel handles the TCP ACK, PSH, and SYN flags internally, and you cannot access them.