You mean othern than 0.0.0.0 or 127.0.0.1? You mean this?
var http = require("http")
var server = http.createServer()
server.listen(80, "192.168.100.1") // or other?
This works for me..
---
Diogo R.
It's not possible right now, it's one of those minor TODOs that no one
ever gets around to. If you want to submit a pull request,
Socket.prototype.connect in lib/net.js is the function you want.
In application code I created a function similar to createConnection
which does:
var s = new net.Socket({ handle:
net._createServerHandle(localAddress) });
s.connect(port, host, cb);
I am not comfortable enough with javascript and the node architecture
yet to submit a patch to net.js.
Thanks,
Maarten O.
On Nov 16, 11:17 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> On Wed, Nov 16, 2011 at 18:10, Maarten <maar...@brightcode.nl> wrote:
> > Hello,
>
> > I need to create connections in Node from a specific IP address on a
> > server with more than one IP address. Unfortunately, theSocketAPI
> > does not support binding to a local address when creating a
> > connection.
>
> > Does anyone know if there is a workaround for this? I already looked
> > at Node's sources, but thebindcall is deeply hidden in the
> > libraries.
>
> > Thanks,
>
> > Maarten
>
> It's not possible right now, it's one of those minor TODOs that no one
> ever gets around to. If you want to submit a pull request,Socket.prototype.connect in lib/net.js is the function you want.
Ben,
I think we should have net.createConnection take an options object
first. Maybe extend Maciej's tls options patch to also cover the net
module? After that binding to a specific address should be trivial to
add (it's just adding an extra bind() call).
- Bert
Sure. Make it so.