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 835635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:51:19+00:00 2026-05-15T04:51:19+00:00

I’m trying to work with sockets and I have such problem In code example:

  • 0

I’m trying to work with sockets and I have such problem

In code example:

setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0')

I have error

AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE'

On Linux machine this attribute is OK but on FreeBSD trere are no any SO_* attributes in module IN. What port should I install to resolve this problem on FreeBDS machine?

Python versions on Linux tested:
2.5.4 and 2.6.4;
on FreeBSD:
2.5.5

I can’t find anything about this module in my book, and googling keyword IN looks like seamless …

update:

I can only bind to address, not to device.

>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> s.bind(("eth0",3040))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in bind
socket.gaierror: [Errno -2] Name or service not known
>>> s.bind(("192.168.33.152",3040))
>>> s.close()

update 2:

… but I’m working with broadcast packets. I’m trying to write daemon which acts like DHCP server.
If I bind to address would I catch broadcast packets? And if I’ll set promiscuous mode on?

  • 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-05-15T04:51:20+00:00Added an answer on May 15, 2026 at 4:51 am

    SO_BINDTODEVICE socket option is not standard and is not supported on FreeBSD. Why can’t you just use regular bind(2) for assigning local address/interface?

    Edit:

    Take a look at the socket object docs.
    Here’s an example.

    Edit 2:

    You didn’t say what exactly you are trying to achieve, so assuming regular TCP/IP client-server.

    IP, being a network-layer protocol (vs. for example, Ethernet, which is a data-link protocol), is not concerned with devices, but addresses. The idea is that you don’t need to bind to a device – the OS takes care of mapping addresses to devices, and maintains a routing table. The only time you need explicit relationship between a socket and a device is when working with broadcast and multicast, where mapping between addresses and interfaces is not obvious.

    Each network interface known to TCP/IP stack is assigned an IP address (see ifconfig(8)). Bind your socket to that IP address and you’ll be all set.

    Hope this helps.

    Edit 3:

    Have you looked into SO_BROADCAST option? Also check out this SO question about raw sockets.

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

Sidebar

Ask A Question

Stats

  • Questions 426k
  • Answers 426k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer afraid it's facebook that extracts the text, add2any just passes… May 15, 2026 at 12:31 pm
  • Editorial Team
    Editorial Team added an answer There's RubyDocTest, but I'd encourage you to look at something… May 15, 2026 at 12:31 pm
  • Editorial Team
    Editorial Team added an answer It sounds like you want something like: int size =… May 15, 2026 at 12:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.