tcpheadererlangethernetgen-tcp

is there any way to get ether/ip headers via gen_tcp?


is there any way to get not only body of incoming message. but also ether/IP headers of it? Now i'm using gen_tcp and receive messages by active controlling process.

for now socket is opened via 'of_driver' in such way:

gen_tcp:connect(IpAddr, Port,  [binary, {packet, raw}, {active, false}],CONNECT_TIMEOUT)

Solution

  • As far as I know, you can't get Ethernet or IP headers through gen_tcp. You could use the procket library to open a raw socket. (The {packet, raw} option passed to gen_tcp doesn't refer to a "raw" socket; it just means that gen_tcp doesn't try to interpret the TCP byte stream to split it into packets.)