Reputation: 3370
I have a Linux application for which there's no source. It listens for incoming TCP connections on a specific port. Because it was mis-designed, it can only handle one connection at a time.
I would like to run multiple instances of this app, and let each of them think that they own that port, by virtualizing their socket creation calls -- i.e. provide a redirection layer which will distribute incoming connections to a pool of these applications, which otherwise would not run because they're contending for that one port.
I'm happy to write the glue code, but it seems likely that there's already some interception solution for socket creation that shouldn't be reinvented. Is there?
Upvotes: 4
Views: 166
Reputation: 36422
You should be able to use a library with LD_PRELOAD
to override the application's use of the socket API. You may want to start by looking at the code of a socksify utility, such as tsocks or socksify from dante as a starting point.
In fact, you could even set up a socks server and use one of those existing utilities to work around the issue.
Upvotes: 3