Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8741623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:20:58+00:00 2026-06-13T11:20:58+00:00

This is a quick question for linux c programming raw sockets. If I wanted

  • 0

This is a quick question for linux c programming raw sockets. If I wanted to just listen to any interface with a raw socket, must I actually bind to an ip address or interface to listen to traffic? From what I understand, I feel like I should be able to just call sock(); and then start recvfrom() traffic. Maybe I’m wrong, but I’ve seen some programs that don’t use it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:20:59+00:00Added an answer on June 13, 2026 at 11:20 am

    You are right, the only thing you will need to do is call socket() and then recvfrom(). Nevertheless be aware of the fact that there are some limitations with listening using SOCK_RAW.

    If you’re not using raw sockets on a “send-and-forget” basis, you will
    be interested in reading the reply packet(s) for your raw packet(s).
    The decision logic for whether a packet will be delivered to a raw
    socket can be enumarated as such:

    1. TCP and UDP packets are never delivered to raw sockets, they are always handled by the kernel protocol stack.

    2. Copies of ICMP packets are delivered to a matching raw socket. For some of the ICMP types (ICMP echo request, ICMP timestamp request,
      mask request) the kernel, at the same time, may wish to do some
      processing and generate replies.

    3. All IGMP packets are delivered to raw sockets: e.g. OSPF packets.

    4. All other packets destined for protocols that are not processed by a kernel subsystem are delivered to raw sockets.

    The fact that you’re dealing with a protocol for which reply packets
    are delivered to your raw socket does not necessarily mean that you’ll
    get the reply packet. For this you may also need to consider:

    1. setting the protocol accordingly while creating your socket via socket(2)system call. For instance, if you’re sending an ICMP
      echo-request packet, and want to receive ICMP echo-reply, you can set
      the protocol argument (3rd argument) to IPPROTO_ICMP).

    2. setting the protocol argument in socket(2) to 0, so any protocol number in the received packet header will match.

    3. defining a local address for your socket (via e.g. bind(2)), so if the destination address matches the socket’s local address, it’ll be
      delivered to your application also.

    For more details you can read e.g. this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is just a quick question to understand correctly what happens when you create
This is just a quick question in C#. I have a scenario where I
Just a quick question about how you would go about implementing this. I want
just a quick question, was trying different ways to accomplish this, but ended with
This is a quick question.I just want to know if it is possible to
just a quick question. I've got this table in a Word template which have
This is just a quick Question. I am writing a feature here that creates
this should be a really quick question. Is there any way to increment the
This is just a quick question. As I understand it, code from a static
quick question. I'm running pygame under linux just to play some audio files. I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.