Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-11

raw socket example

5 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

Hi,

I am looking for some examples of writing linux raw socket programs in free pascal, anyone had experience on that?

Thanks a lot!

Daniel Gaspary
to leledumbo

Need to change the fpsocket function call.

From fpSocket(AF_INET,SOCK_STREAM,0)
to fpSocket(AF_INET,SOCK_RAW,0);

Is possible that the "0" needs to be changed too.

leledumbo wrote 13 lines
FPC docs has them: http://www.freepascal.org/docs-html/rtl/sockets/fpaccept.html (server) http://www.freepascal.org/docs-html/rtl/sockets/fpconnect.html (client) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/raw-socket-example-tp5723096p5723097.html Sent from the Free Pascal - General mailing list . _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Dmitry Boyarintsev
to Daniel Gaspary
Daniel Gaspary wrote 8 lines
Need to change the fpsocket function call. From fpSocket(AF_INET,SOCK_STREAM,0) to fpSocket(AF_INET,SOCK_RAW,0); Is possible that the "0" needs to be changed too.

Just keep in mind that reading such socket is tricky. There's no more IP address (as shown in the example). The whole protocol stack needs to be handled manually.

I don't think there's any publish FPC raw-socket example. The easiest way is to find C raw-socket example and port it to pascal.

thanks,
Dmitry