Open Cu3PO42 opened 3 days ago
I like this idea. From briefly looking at the code, I don't see any obstacles - if the inherited file descriptor represents a listening socket, then a ServerSocketChannel should be returned by System.inheritedChannel, which is exactly what we need.
Is your feature request related to a problem? Please describe. I would like to implement socket activation for an application using Java WebSocket, specifically Robocode Tank Royale. Socket activation lets systemd start an application on demand when others try to connect to it.
Describe the solution you'd like Using
System.inheritedChannel
you can get access to a socket that was passed to the application as file descriptor 1. I'd like for there to be a constructor forWebSocketServer
that, instead of taking a port and listen address, accepts a pre-existingChannel
.Describe alternatives you've considered My specific use-case would also be solved by a constructor that calls
System.inheritedChannel
itself, though I believe the other one I proposed is more flexible. SocketSocket activation is not easily replaced and there is no clean strategy to emulate it without support from the application.
Thank you for consideration!