Skip to content

socketcand: support connecting via a Unix domain socket - #2113

Open
smoltafet wants to merge 1 commit into
hardbyte:mainfrom
smoltafet:feat/socketcand-unix-socket
Open

smoltafet wants to merge 1 commit into
hardbyte:mainfrom
smoltafet:feat/socketcand-unix-socket

Conversation

@smoltafet

Copy link
Copy Markdown

Summary of Changes

  • SocketCanDaemonBus gains a unix_socket_path argument: when given, it connects to socketcand through a Unix domain socket (AF_UNIX) instead of TCP, as requested in Socketcand UNIX Socket Support #2018. host/port are then neither required nor allowed.
  • host and port are now optional (default None); passing neither address form, or a mix of both, raises CanInitializationError before any connection attempt. Platforms without AF_UNIX raise the same error.
  • tcp_tune is disabled with a warning for Unix sockets (same pattern as the existing Windows case).
  • connect_to_server now takes a single address (a (host, port) tuple or a socket path), which is what socket.connect() accepts for both families.
  • Tests: a fake socketcand server in test/test_socketcand.py performs the real handshake plus a send/receive round-trip over both a Unix domain socket and TCP (regression), and covers the invalid configuration combinations.
  • News fragment added under doc/changelog.d/.

Related Issues / Pull Requests

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other (please describe):

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment for towncrier.
  • All checks and tests pass (tox).

Additional Notes

Verified locally: pytest test/test_socketcand.py passes (8 tests, including the 4 new ones), the public can.interface.Bus(interface="socketcand", channel="can0", unix_socket_path=...) route connects against the fake server, and black --check / ruff check (project pins) are clean on the changed files. Full tox was not run in my environment, and the interface .rst page was not extended — happy to add that if you prefer it in the same PR.

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.

Socketcand UNIX Socket Support

1 participant