Skip to content

Conversation

mpilquist
Copy link
Member

@mpilquist mpilquist commented Apr 8, 2025

Fixes #3560

This PR revamps fs2.io.net in a number of significant ways:

  • Unifies support for IP and Unix sockets in to a single set of operations -- connect for clients and bind for servers, both taking the new com.comcast.ip4s.GenSocketAddress type, which is a supertype of SocketAddress[Host] and UnixSocketAddress
  • Resultantly adds support for socket options on unix sockets
  • Deprecates SocketGroup - there has never really been a great reason to manage explicit thread pools / async socket groups & the API was JVM only. With the new polling system, there's even less of a reason to ever use the explicitly managed socket groups.
  • Deprecates UnixSockets as there's no utility provided that's not also provided by Network now
  • Deprecates client, server, serverResource in favor of connect, bindAndAccept, bind
  • Introduces ServerSocket, which provides the bound address of the server socket, access to options, and a stream of client sockets.
  • Introduces SocketInfo as a supertype of Socket and ServerSocket.
  • Introduces address: GenSocketAddress on SocketInfo and peerAddress: GenSocketAddress on Socket, replacing localAddress and remoteAddress (each of type F[SocketAddress[IpAddress]].
  • Deprecating isOpen on Socket which is a vestige from when there was a close method.

Datagram sockets have been similarly revamped:

  • openDatagramSocket has been replaced with bindDatagramSocket, taking a GenSocketAddress
  • As of this PR, datagrams over unix sockets are only supported on the JVM, via jnr-unixsocket (JEP-380 doesn't support datagrams). Node.js doesn't have built-in support for datagrams over unix sockets, though we could add via a dependency. Datagram sockets, in general, are not currently implemented on native.

Updates to downstream projects:

@mpilquist
Copy link
Member Author

Going to merge this one this week unless there's any objections.

@mpilquist mpilquist merged commit 6a5d774 into main Sep 5, 2025
33 checks passed
@mpilquist mpilquist deleted the topic/net2 branch September 5, 2025 10:55
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.

Improve unix sockets support
2 participants