On 6/9/2020 7:59 AM, Bogdan Popa wrote:
George Neuner writes: > Multiple Racket applications *should* all be able to listen on the > same port without having been spawned from the same ancestor process. > If that isn't working now, something has gotten hosed. I don't know whether this used to work in the past or not, but currently only `SO_REUSEADDR' is set on TCP sockets: https://github.com/racket/racket/blob/60bf8f970e97caae391bfe919b78c370b2d01bdd/racket/src/rktio/rktio_network.c#L1427 I think we'd need to also set `SO_REUSEPORT', which is not available on all platforms, to support multiple processes listening on the same port without reusing file descriptors.
It has been discussed before, but perhaps now, with RacketCS imminent, the socket functions should be changed / expanded to allow changing options without resorting to FFI.
AFAICS, the functionality of SO_REUSEPORT (if not the verbatim option) is available on all supported platforms. Granted it is (relatively) a recent addition to both Linux and Windows.
Android doesn't support it, but AFAIK, Android is not considered a supported system.
> I'm not sure what you mean by "sharing" a listener, but using a > single listener with a pool of processing places actually is possible > (though tricky). I mean passing a `tcp-listener?' around between places so that each place can call `tcp-accept' on it. Something like this: #lang racket/base (require racket/place racket/tcp) (define ch (place ch (define listener (place-channel-get ch)) (tcp-accept listener) (place-channel-put 'ok))) (module+ main (define listener (tcp-listen 9999 512 #t)) (place-channel-put ch listener) (place-channel-get ch)) Currently, this fails with: place-channel-put: contract violation expected: place-message-allowed? given: #<tcp-listener> context...: ... My understanding is that there's nothing preventing this from working apart from the fact that no one's yet added support for this in the rktio layer. As you mentioned, though, even if this was supported we might run into other limitations when running many places at once.
Only serialized functions can be passed between place ... and the receiving place still has to have imported the libraries (if any) necessary to understand it. I don't know if a listener even can be serialized, though ... AFAIK a serializable function has to be compiled that way.
George  https://docs.racket-lang.org/web-server-internal/closure.html -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/ea9627a2-34d7-0c09-8246-32fd2d955c25%40comcast.net.