0

I have a question. So what I am trying to accomplish is sending and HTTP request. I have looked into raw sockets and such, but I cannot see how I would send an HTTP request in which I can set the source address / port, etc. Thanks!

Kirill Kobelev
  • 10,252
  • 6
  • 30
  • 51
user2484067
  • 109
  • 1
  • 3
  • 10
  • If you plan to use `SOCK_RAW`, then you will have to create your own IP headers and implement TCP over that in order to talk to an HTTP server. This will involve a lot of work, dealing with all the windowing, congestion control, retransmission, etc., which are required for TCP. It would be easier to use a `SOCK_STREAM` over a `PF_INET` socket, and use the TCP implementation provided by your OS. – jxh Jul 16 '13 at 21:32
  • Do you have any code? have you tried anything? Also, as jxh mentions, do you really mean `SOCK_RAW`, or do you want to open a TCP connection and your problem is formulating a HTTP header? – Macattack Jul 16 '13 at 21:34
  • @jxh Can I set the source address with SOCK_STREAM or PF_INIT on Linux? – user2484067 Jul 16 '13 at 21:37
  • Yes you can, please see http://www.gnu.org/software/libc/manual/html_node/Inet-Example.html -- second result on google. – Scotty Bauer Jul 16 '13 at 21:41
  • @user2484067: Do you mean you want to spoof being a different source than the actual machine you are establishing a connection from? In any case, `bind()` is the call that does this, however, it will fail if the IP address you set it to is not actually set to any interface configured on the machine. – jxh Jul 16 '13 at 21:47

0 Answers0