0

Is it possible to send the IP & TCP headers before sending the payload (so there are two calls to the socket's send function)? While I'm sure you can 'do it' with raw sockets, I'm not sure if the network devices (e.g., switches) will be able to handle it. If it isn't possible, could you please explain the low level networking concepts which prevent this from working (obviously as briefly as possible)?

Thanks.

  • Either you can do it or you can't. If raw sockets produces some output that the switches cannot handle, then it hasn't "done it", since doing it would be producing the *correct* output, otherwise it would be doing something else. – David Schwartz Oct 13 '13 at 00:35

1 Answers1

-1

The 'low level concept' is that the header has to be in the same packet as the payload for which it is the packet header, by definition, and that raw send() almost certainly puts what you give it onto the wire as a single packet.

You should investigate writev().

user207421
  • 305,947
  • 44
  • 307
  • 483
  • So are you saying that, while it is possible to use raw sockets to send the ip & tcp headers out first, the receiving device would not be able to handle it? And how do you define a single packet? If a frame is a 'single packet' then I guess I'm asking if I can send the frame part by part... Sorry for the stupid questions - really don't know much about this stuff. –  Oct 13 '13 at 00:43
  • Ok. So if a switch receives an IP header and a TCP header, why can't it wait for the rest of the 'frame' to arrive? After receiving those pieces of information it should know how much information it is expecting right? What stops it from waiting for the rest to arrive? I guess this is the low-level detail I was after (sorry if I wasn't clear). –  Oct 14 '13 at 04:34