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

  • SEARCH
  • Home
  • 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 8254207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:06:50+00:00 2026-06-08T01:06:50+00:00

I implement bridge by taking packets from nfqeueue , open socket to the eth

  • 0

I implement bridge by taking packets from nfqeueue , open socket to the eth card and send the packets (i have some logic in the middle).

i am new to cpp and low level , so i might ask stupid questions.

if i understand correct i shouldn’t open-close the socket for every packet.
i write my code based on this example – http://austinmarton.wordpress.com/2011/09/14/sending-raw-ethernet-packets-from-a-specific-interface-in-c-on-linux/

i open socket like this:

sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW))

my question are:
1. for how long the socket alive?
2. how can i check if the socket i still open?
3. how do i close it? i saw the shutdown , but i didnt know if this is the API?
4. can someone direct me to an example in production level. means handling socket exception …

Thank you

  • 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-08T01:06:51+00:00Added an answer on June 8, 2026 at 1:06 am

    Keep that socket open as long as you have frames to send or receive. Close the socket with normal close(2). Here’s another raw sockets tutorial for you – http://www.tenouk.com/Module43a.html

    shutdown(2) only makes sense with TCP, not at all relevant here.

    Edit 0:

    There’s no connection, you are talking ethernet here.

    Do yourself a favor and read this book – TCP/IP Illustrated, Volume 1: The Protocols. by W. Richard Stevens – will save you ton of confusion.

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

Sidebar

Related Questions

I had spend some time on this Bridge pattern example from wikipedia , however,
I'd like to hide system specific implementations from my application logic. I have chosen
I read raw socket tutorial in order to implement my own bridge (i capture
I need some help in IOS Socket programming. I have implemented a successful TCP
I'm am getting ready to attempt to implement Scripting Bridge for the first time,
I implement an app with some list of process IDs. I used Runtime.getRuntime().exec(ps) to
I want to implement a simple script to do some boring housekeeping on my
I'm basically just posting tonight to get some feedback from some of you more
I have a studentadministration application. Now I have to implement a new part of
Is it easy to implement Flex Ajax Bridge with ColdFusion? Where can I learn

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.