janestreet / async_extra

Jane Street Capital's asynchronous execution library (extra)
MIT License
15 stars 8 forks source link

Allowing bound socket in Tcp.connect ? #14

Closed psteckler closed 4 years ago

psteckler commented 5 years ago

I want to have a client connect with a socket bound to a particular IP address. For example, I might want to have the IP address be 127.0.0.8 instead of the default localhost IP.

Tcp.connect expects the socket to be Unconnected, rather than Bound, though. I can use Async.Socket.connect instead, but then I lose things like the timeout feature of Tcp.connect.

Any chance of removing this restriction?

snowleopard commented 4 years ago

@psteckler It appears that after this issue was created, the library was refactored and Tcp.connect moved to async_unix.

Tcp.connect accepts the argument where_to_connect, which can be created using of_host_and_port where I suppose you can specify 127.0.0.8 as the desired IP address.

I'm closing this issue but feel free to reopen it if needed, ideally, in the async_unix repository to make it more visible.