Re: Create a listening socket in PHP ?

From: Luke Ross (lukeross_at_sys3175.co.uk)
Date: 10/20/03


Date: Mon, 20 Oct 2003 14:52:19 +0100

Hi,

127.0.0.1 wrote:
> How does one go about creating a listening socket in a PHP script.
>
> I'm trying to work out a way of finding out my IP address (dynamic,
> behind NAT) and I can't use the normal http idea to get it (due to
> stuff proxy by ISP).
>
> SO what I thought was to write a protected PHP script which listend for
> ONE request on that port - and send back the IP bound on that port.
>
> So from my linux box I would:
>
> 1. GET http://xyz.com/wait.php?port=2002
> 2. telnet xyz.com 2002
>
> Thus geting my IP address ...
>
> Any ideas ?

Why not just look at the X-Forwarded-For: and Via: headers?

Luke