Skip to content

Conversation

@JaewonAC
Copy link

Hello. Thanks a lot for wonderful library.

I'm using it in my Raspberry pi
My RPi's
eth0 is connected to company network
wlan0 is connected to A5100 sony mirrorless camera

I guess ControlPoint's socket is kinda stick to eth0.
So I modified ControlPoint to support binding socket socket to specific interface.

I hope this may helpful.

# Set the socket to broadcast mode.
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
if interface:
sock.setsockopt(socket.SOL_SOCKET, 25, str(interface + '\0').encode('utf-8'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely minor nitpick: Everything else in this file looks like it uses 4 spaces for indentation, but you've only got 2 spaces here.

What does 25 mean in the setsockopt call?

Copy link
Owner

@Bloodevil Bloodevil Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use 4 spaces like other line.

is that 25 optname...?
socket.setsockopt(level, optname, value: int)
socket.setsockopt(level, optname, value: buffer)
socket.setsockopt(level, optname, None, optlen: int)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happened to dig into this myself the other day, 25 is indeed optname and at least in terms of Linux based sockets, it refers to SO_BINDTODEVICE as seen here: https://github.com/torvalds/linux/blob/169e77764adc041b1dacba84ea90516a895d43b2/include/uapi/asm-generic/socket.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants