in reply to Using socket instead of pcap

Why, yes! Gosh, golly gee; it sure would!

So have you written code which does so?

Or did you really intend to ask "Will you -- pretty please with sugar on it -- do the work for me?"

If so, I'd suggest reading On asking for help and How do I post a question effectively?, putting together some code, and then improving this thread by posting code, along with a description of how it fails to do your job and the verbatim error messages (if any).

Bottom line: we're here to help you learn; not to do the job for you.