<div>I'll get:</div><div><br></div><br><div class="gmail_quote">On Tue, Feb 8, 2011 at 11:22 AM, Uri Guttman <span dir="ltr"><<a href="mailto:uri@stemsystems.com">uri@stemsystems.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
>>>>> "AS" == Antonio Sun <<a href="mailto:antoniosun@lavabit.com">antoniosun@lavabit.com</a>> writes:<br>
<br>
AS> $sock = new IO::Socket::INET ( LocalHost => '0.0.0.0',<br>
AS> LocalPort => '80',<br>
AS> Proto => 'tcp',<br>
AS> Listen => 30,<br>
AS> Reuse => 1);<br>
<br>
don't use the indirect call of new Class. make it Class->new(). . . </blockquote><div><br></div><div>OK, will change that once script is working. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
AS> which will fail because my port 80 on localhost is used by web server. <br>
AS> How can I change the code to listen on the 2nd ip address? <br>
<br>
AS> I.e., my current IP address is 192.168.0.100, it is<br>
AS> also accessible at 192.168.0.101. I want that<br>
AS> visiting 192.168.0.100 will land to my normal web server, while<br>
AS> visiting 192.168.0.101 will be handled by the code above. <br>
<br>
kind of obvious. you set localhost to the ip you want. that binds the<br>
listen socket to that and the port pair which is unique on your box.<br>
</blockquote></div><br><div>Sorry, I still can't figure it out, even it is so obvious to you:</div><div><br></div><div>If I use,</div><div><br></div><div><div>$sock = new IO::Socket::INET ( LocalHost => '0.0.0.0',</div>
<div> LocalPort => '80',</div><div> Proto => 'tcp',</div><div> Listen => 30,</div><div> Reuse => 1);</div>
<div><br></div><div>if (!defined($sock)) {</div><div> print "error : cannot bind : $! exit\n";</div><div> exit(1);</div><div>}</div><div><br></div></div><div>I'll get:</div><div><br></div><div>
error : cannot bind : Address already in use exit</div><div><br></div><div>I assume it fails because my port 80 is currently used by web server.</div><div><br></div><div>If I use</div><div><br></div><div><div> $sock = new IO::Socket::INET ( LocalHost => '192.168.0.101',</div>
</div><div><br></div><div>I still get</div><div><br></div><div> error : cannot bind : Address already in use exit</div><div><br></div><div>If I use </div><div><br></div><div> $sock = new IO::Socket::INET ( LocalHost => '192.168.0.104',</div>
<div><br></div><div><div>I'll get:</div></div><div><br></div><div> error : cannot bind : Cannot assign requested address exit</div><div><br></div><div>Please help. </div><div><br></div><div>thanks</div><div><br></div>