eio icon indicating copy to clipboard operation
eio copied to clipboard

(draft) Eio.Net.connect: optionally bind before connect

Open art-w opened this issue 2 years ago • 2 comments

I'm looking to port some existing code which does a bind before connect and couldn't find a way to do it with Eio. I wasn't familiar with this trick, but it's apparently useful when you have multiple public IPs and need to control which one will be seen by the server.

Let me know if there's a better way to do this!.. I'm marking this PR as a draft because I'm starting to think this might actually require a new bind_connect function, to also expose the REUSEADDR/PORT options as they only make sense when ?bind is set.

art-w avatar Mar 20 '24 17:03 art-w

I'd interested to hear what made you select this approach over exposing a bind function to the user?

SGrondin avatar Mar 21 '24 13:03 SGrondin

This seems reasonable to me.

Possibly we should have a dedicated options argument (extensible variant) as there will likely be loads more special features that could be added (see e.g. #575).

e.g. something like

Net.connect net dst
   ~options:[Source_addr src]

Need to decide what to do if a backend doesn't support an option. e.g. mirage-tcpip doesn't look like it supports this (https://github.com/mirage/mirage-tcpip/blob/75382e296ff6779338c3b7b069c885d5d8e10eeb/src/core/tcp.mli#L76).

talex5 avatar Mar 23 '24 10:03 talex5