FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP socket and NAT
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP socket and NAT [message #177119] Thu, 23 February 2012 08:58 Go to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
This is not strictly a PHP question, it just springs into my mind while
coding sockets in PHP.

Assuming that I am communicating with 2 persons who are in the same LAN, say
A & B.

When I send some data to A, do I have to take care of the NAT (network
address translation) ?

Will the sockets take care of it automatically ?

Thanks.
Re: PHP socket and NAT [message #177120 is a reply to message #177119] Thu, 23 February 2012 10:32 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 2/23/2012 9:58 AM, SL wrote:
> This is not strictly a PHP question, it just springs into my mind while
> coding sockets in PHP.
>
> Assuming that I am communicating with 2 persons who are in the same LAN, say
> A& B.
>
> When I send some data to A, do I have to take care of the NAT (network
> address translation) ?
>
> Will the sockets take care of it automatically ?
>
> Thanks.
>
>

Hi,


NAT typically is used to change IP-addresses (and maybe port).
If A and B are in the same LAN I expect they can address each other
directly.
For example:
A IP: 192.168.178.22
B IP: 192.168.178.25

Once you go outside your LAN, you (might) need NAT.

And sockets have little to do with NAT.
A IP package arrives at a certain IP on a certain port: If some socket
is listening on that port on that machine, the package will be handled
by the listening process.

NAT itself is performed by routers and such, not by some service
listening to a port.

SO in short: No you have to care about it.

Disclaimer: If you are talking IP6, things are different.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: PHP socket and NAT [message #177121 is a reply to message #177120] Thu, 23 February 2012 10:41 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Feb 23, 10:32 am, Erwin Moller <erwinmolleruse...@xs4all.nl> wrote:
> SO in short: No you have to care about it.
I think you meant to say:
"No you do not have to care about it."
Re: PHP socket and NAT [message #177122 is a reply to message #177120] Thu, 23 February 2012 10:52 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 2/23/2012 11:32 AM, Erwin Moller wrote:
> On 2/23/2012 9:58 AM, SL wrote:
>> This is not strictly a PHP question, it just springs into my mind while
>> coding sockets in PHP.
>>
>> Assuming that I am communicating with 2 persons who are in the same
>> LAN, say
>> A& B.
>>
>> When I send some data to A, do I have to take care of the NAT (network
>> address translation) ?
>>
>> Will the sockets take care of it automatically ?
>>
>> Thanks.
>>
>>
>
> Hi,
>
>
> NAT typically is used to change IP-addresses (and maybe port).
> If A and B are in the same LAN I expect they can address each other
> directly.
> For example:
> A IP: 192.168.178.22
> B IP: 192.168.178.25
>
> Once you go outside your LAN, you (might) need NAT.
>
> And sockets have little to do with NAT.
> A IP package arrives at a certain IP on a certain port: If some socket
> is listening on that port on that machine, the package will be handled
> by the listening process.
>
> NAT itself is performed by routers and such, not by some service
> listening to a port.
>
> SO in short: No you have to care about it.
>
> Disclaimer: If you are talking IP6, things are different.
>
> Regards,
> Erwin Moller
>

An additional example of NAT that makes things clear.
This is how it was explained to me when I wanted to know about NAT.

Suppose you have 10 computers on your LAN, and 1 internet gateway (some
ADSL modem for example).
All you 10 computers can connect to the internet because they use the
routers IP address as the gateway.

The router has an INTERNAL (LAN-side) IP address.
Let's say this LAN-IP is 192.168.178.1

The router also has an EXTERNAL (Internet-side) IP address.
Let's say internet-side IP is 69.147.94.94. (I made the numbers up)

Now, suppose a few people on the LAN are visiting some websites.
Suppose compA has IP address 192.168.178.22. (On the LAN)
Suppose compA has IP address 192.168.178.50. (On the LAN)

CompA (192.168.178.22): requests www.google.com
CompB: (192.168.178.50)requests www.php.net

The router receives these requests from the LAN side, and sends the
requests to www.google.com and www.php.net.
The servers from Google and PHP answer the requests, and send them back
to the router's IP address (being 69.147.94.94).

Now the problem: How should the router handle these answers? Should it
send them to 192.168.178.22 or 192.168.178.50, or even another IP on the
LAN?

This is where NAT comes into the picture.
It works like this:
1) Router receives request from 192.168.178.22 (=LAN)for www.google.com.
2) Router thinks up some random port that is not is use, eg 33000.
3) Router stores this portnumber (33000) in a table together with the
requesting LAN IP-address (192.168.178.22).
4) Router sends the request to www.google.com TOGETHER with the
instruction to answer on port 33000.
5) When Google answers, the router looks up the portnumber, ans sees
what (internal) IP-address made this request. This way the router can
see which internal IP-adress made what request because they all get
random assigned portnumbers.

That is NAT in short.

So I don't expect you have to worry about that in your case.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: PHP socket and NAT [message #177123 is a reply to message #177121] Thu, 23 February 2012 10:53 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 2/23/2012 11:41 AM, Captain Paralytic wrote:
> On Feb 23, 10:32 am, Erwin Moller<erwinmolleruse...@xs4all.nl> wrote:
>> SO in short: No you have to care about it.
> I think you meant to say:
> "No you do not have to care about it."
>

Yes indeed!
Thanks for correcting.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: PHP socket and NAT [message #177124 is a reply to message #177119] Thu, 23 February 2012 11:40 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
SL wrote:
> This is not strictly a PHP question, it just springs into my mind while
> coding sockets in PHP.
>
> Assuming that I am communicating with 2 persons who are in the same LAN, say
> A & B.
>
> When I send some data to A, do I have to take care of the NAT (network
> address translation) ?
>
> Will the sockets take care of it automatically ?
>

the router will if it is going through a NAT router, but if its on the
same LAN chances are it wont be.


In short just connect to an IP address and let the routing
infrastructure take care of everything else.

> Thanks.
>
>
Re: PHP socket and NAT [message #177126 is a reply to message #177119] Thu, 23 February 2012 13:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/23/2012 3:58 AM, SL wrote:
> This is not strictly a PHP question, it just springs into my mind while
> coding sockets in PHP.
>
> Assuming that I am communicating with 2 persons who are in the same LAN, say
> A& B.
>
> When I send some data to A, do I have to take care of the NAT (network
> address translation) ?
>
> Will the sockets take care of it automatically ?
>
> Thanks.
>
>

I'm assuming you're talking about talking to two people on a remote LAN,
and that LAN uses NAT to connect to the internet.

The first question is - who's connecting to whom?

If the remote systems are connecting to you, then there's no problem.
However, if you are trying to connect to them, there's a lot more work
involved. The router must be set up with port forwarding and you have
to connect to the correct port to forward to the proper machine.

You can find more information in a TCP/IP newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP socket and NAT [message #177127 is a reply to message #177122] Thu, 23 February 2012 13:04 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
>> NAT typically is used to change IP-addresses (and maybe port).
>> If A and B are in the same LAN I expect they can address each other
>> directly.
>> For example:
>> A IP: 192.168.178.22
>> B IP: 192.168.178.25
>>
>> Once you go outside your LAN, you (might) need NAT.
>>
>> And sockets have little to do with NAT.
>> A IP package arrives at a certain IP on a certain port: If some
>> socket is listening on that port on that machine, the package will
>> be handled by the listening process.
>>
>> NAT itself is performed by routers and such, not by some service
>> listening to a port.
>>
>> SO in short: No you have to care about it.
>>
>> Disclaimer: If you are talking IP6, things are different.
>>
>> Regards,
>> Erwin Moller
>>
>
> An additional example of NAT that makes things clear.
> This is how it was explained to me when I wanted to know about NAT.
>
> Suppose you have 10 computers on your LAN, and 1 internet gateway
> (some ADSL modem for example).
> All you 10 computers can connect to the internet because they use the
> routers IP address as the gateway.
>
> The router has an INTERNAL (LAN-side) IP address.
> Let's say this LAN-IP is 192.168.178.1
>
> The router also has an EXTERNAL (Internet-side) IP address.
> Let's say internet-side IP is 69.147.94.94. (I made the numbers up)
>
> Now, suppose a few people on the LAN are visiting some websites.
> Suppose compA has IP address 192.168.178.22. (On the LAN)
> Suppose compA has IP address 192.168.178.50. (On the LAN)
>
> CompA (192.168.178.22): requests www.google.com
> CompB: (192.168.178.50)requests www.php.net
>
> The router receives these requests from the LAN side, and sends the
> requests to www.google.com and www.php.net.
> The servers from Google and PHP answer the requests, and send them
> back to the router's IP address (being 69.147.94.94).
>
> Now the problem: How should the router handle these answers? Should it
> send them to 192.168.178.22 or 192.168.178.50, or even another IP on
> the LAN?
>
> This is where NAT comes into the picture.
> It works like this:
> 1) Router receives request from 192.168.178.22 (=LAN)for
> www.google.com. 2) Router thinks up some random port that is not is
> use, eg 33000. 3) Router stores this portnumber (33000) in a table
> together with the requesting LAN IP-address (192.168.178.22).
> 4) Router sends the request to www.google.com TOGETHER with the
> instruction to answer on port 33000.
> 5) When Google answers, the router looks up the portnumber, ans sees
> what (internal) IP-address made this request. This way the router can
> see which internal IP-adress made what request because they all get
> random assigned portnumbers.
>
> That is NAT in short.
>
> So I don't expect you have to worry about that in your case.
>

This example clears the air. So the key is the router comes up with random
port number, and the reply specifies that port number.

Thanks a lot.
Re: PHP socket and NAT [message #177128 is a reply to message #177126] Thu, 23 February 2012 13:09 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
>
> I'm assuming you're talking about talking to two people on a remote
> LAN, and that LAN uses NAT to connect to the internet.
>
> The first question is - who's connecting to whom?
>
> If the remote systems are connecting to you, then there's no problem.
> However, if you are trying to connect to them, there's a lot more work
> involved. The router must be set up with port forwarding and you have
> to connect to the correct port to forward to the proper machine.
>
> You can find more information in a TCP/IP newsgroup.

I am thinking of the scenario where I am talking to 2 persons via the
internet, and these 2 persons are in the same LAN, something like chatting.
So the problem in my mind is that these 2 persons have the same IP.

Thanks.
Re: PHP socket and NAT [message #177131 is a reply to message #177128] Thu, 23 February 2012 13:19 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Feb 23, 1:09 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>> I'm assuming you're talking about talking to two people on a remote
>> LAN, and that LAN uses NAT to connect to the internet.
>
>> The first question is - who's connecting to whom?
>
>> If the remote systems are connecting to you, then there's no problem.
>> However, if you are trying to connect to them, there's a lot more work
>> involved.  The router must be set up with port forwarding and you have
>> to connect to the correct port to forward to the proper machine.
>
>> You can find more information in a TCP/IP newsgroup.
>
> I am thinking of the scenario where I am talking to 2 persons via the
> internet, and these 2 persons are in the same LAN, something like chatting.
> So the problem in my mind is that these 2 persons have the same IP.
No they don't, the local network will not allow it. They will have
different IP addresses.
Re: PHP socket and NAT [message #177134 is a reply to message #177127] Thu, 23 February 2012 13:37 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
sl@exabyte wrote:

>> That is NAT in short.
>>
>> So I don't expect you have to worry about that in your case.
>>
>
> This example clears the air. So the key is the router comes up with random
> port number, and the reply specifies that port number.
>

Yes, and the router maintains a state table that associates that port
with an internal machine IP address and original originating port, and
sends the packet back correctly.

There are a few wrinkles with some protocols that expect to be able to
open a connection back to the original machine - ftp is/can be one such.

There a bit more intelligence is required by the router. It sees there
is an existing outbound ftp link and therefore knows what to do with
incoming requests to open the 'back channel'..as long as only one
machine on the LAN is ftp-ing that remote machine.;-)




> Thanks a lot.
>
>
Re: PHP socket and NAT [message #177135 is a reply to message #177128] Thu, 23 February 2012 13:37 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 2/23/2012 2:09 PM, sl@exabyte wrote:
>>
>> I'm assuming you're talking about talking to two people on a remote
>> LAN, and that LAN uses NAT to connect to the internet.
>>
>> The first question is - who's connecting to whom?
>>
>> If the remote systems are connecting to you, then there's no problem.
>> However, if you are trying to connect to them, there's a lot more work
>> involved. The router must be set up with port forwarding and you have
>> to connect to the correct port to forward to the proper machine.
>>
>> You can find more information in a TCP/IP newsgroup.
>
> I am thinking of the scenario where I am talking to 2 persons via the
> internet, and these 2 persons are in the same LAN, something like chatting.
> So the problem in my mind is that these 2 persons have the same IP.

You don't have to worry about that.
On the same LAN you will have a problem when 2 persons have the same IP
address.
It is forbidden and the Bit-police will find you and throw you into the
Valley of the Lost Bits!

I think you better tell us exactly what your situation is and how these
clients are connected (VPN? Internet? Plain LAN?).
It is a little confusing (for me) you keep talking about the internet
and LAN as if they are interchangeable.
You CAN set up a LAN that connects remote locations and make them act as
if they were in the same physical location/LAN, but then you still
cannot have 2 identical IP address.

Regards,
Erwin Moller

>
> Thanks.
>
>


--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: PHP socket and NAT [message #177137 is a reply to message #177128] Thu, 23 February 2012 13:50 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
sl@exabyte wrote:
>> I'm assuming you're talking about talking to two people on a remote
>> LAN, and that LAN uses NAT to connect to the internet.
>>
>> The first question is - who's connecting to whom?
>>
>> If the remote systems are connecting to you, then there's no problem.
>> However, if you are trying to connect to them, there's a lot more work
>> involved. The router must be set up with port forwarding and you have
>> to connect to the correct port to forward to the proper machine.
>>
>> You can find more information in a TCP/IP newsgroup.
>
> I am thinking of the scenario where I am talking to 2 persons via the
> internet, and these 2 persons are in the same LAN, something like chatting.
> So the problem in my mind is that these 2 persons have the same IP.
>

Well the whole point of NAT security wise is that you CANNOT talk to
them directly from OUTSIDE. THEY must open a dialogue from inside that
NAT firewall. Then you can respond to them on whatever port they picked
- or their router picked for them.

Unless you set things up so they will answer on different PORT numbers.

using passthrough on the router etc.

The way you normally do chat is to have a server in the middle, so that
everybody 'connects' to that server, and the server then maintains a
table of who is on what ip address and port..and can send the data back
to them.

But a web server is not the way to do that in real time - rather you
need a purpose built daemon to vector chat messages to people. If you
want real time.

If you are happy to have the client poll, well then its pretty simple -
they connect to your web server using a cookie or GET or POST variable
to ID themselves, and any messages for them get added to their view
when next they poll the server. You can speed that up and make it more
efficient with javascript or i-frames and so on.

I am still unclear as to what you want to do, but the key thing is you
cant 'push' unsolicited data to a NAT translated machine from outside.
That machine MUST request the data.

And that means that the person you want to talk to must have an active
live running connection that he has initiated, to your server. And keep
polling it.

Because web BROWSERS don't accept data they haven't requested either.
They only 'listen' for as long as it takes to get a response they
expect. They may keep the TCP/IP connection alive between times, but
they are not necessarily listening on it. And in any case its not
reliable behaviour.

Because they may not.










> Thanks.
>
>
Re: PHP socket and NAT [message #177138 is a reply to message #177131] Thu, 23 February 2012 13:53 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Captain Paralytic wrote:
> On Feb 23, 1:09 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>>> I'm assuming you're talking about talking to two people on a remote
>>> LAN, and that LAN uses NAT to connect to the internet.
>>> The first question is - who's connecting to whom?
>>> If the remote systems are connecting to you, then there's no problem.
>>> However, if you are trying to connect to them, there's a lot more work
>>> involved. The router must be set up with port forwarding and you have
>>> to connect to the correct port to forward to the proper machine.
>>> You can find more information in a TCP/IP newsgroup.
>> I am thinking of the scenario where I am talking to 2 persons via the
>> internet, and these 2 persons are in the same LAN, something like chatting.
>> So the problem in my mind is that these 2 persons have the same IP.

> No they don't, the local network will not allow it. They will have
> different IP addresses.

They do as far as the outside world is concerned.

And the network doesn't *disallow* it inside the NAT area either, it
simply stops things working for those two machines :-)

As anyone who has done it in the olden days of static IP addresses will
tell you.

How we sobbed for joy when DHCP on PC's arrived...try managing upwards
of 100 machines on the same LAN..with static IP addresses..
Re: PHP socket and NAT [message #177140 is a reply to message #177138] Thu, 23 February 2012 14:25 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Feb 23, 1:53 pm, The Natural Philosopher <t...@invalid.invalid>
wrote:
> Captain Paralytic wrote:
>> On Feb 23, 1:09 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>>>> I'm assuming you're talking about talking to two people on a remote
>>>> LAN, and that LAN uses NAT to connect to the internet.
>>>> The first question is - who's connecting to whom?
>>>> If the remote systems are connecting to you, then there's no problem.
>>>> However, if you are trying to connect to them, there's a lot more work
>>>> involved.  The router must be set up with port forwarding and you have
>>>> to connect to the correct port to forward to the proper machine.
>>>> You can find more information in a TCP/IP newsgroup.
>>> I am thinking of the scenario where I am talking to 2 persons via the
>>> internet, and these 2 persons are in the same LAN, something like chatting.
>>> So the problem in my mind is that these 2 persons have the same IP.
>> No they don't, the local network will not allow it. They will have
>> different IP addresses.
>
> They do as far as the outside world is concerned.
But that is as far as the outside world is concerned. They will still
not have the same IP addresses.

> And the network doesn't *disallow* it inside the NAT area either, it
> simply stops things working for those two machines :-)
The local network will not allow 2 machines with the same IP address
to function on it (communication wise)
Re: PHP socket and NAT [message #177141 is a reply to message #177131] Thu, 23 February 2012 16:03 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
> No they don't, the local network will not allow it. They will have
> different IP addresses.

Sorry, folks. When I say same IP, I mean the external IP.

I am trying to add something to a chat application; a server is involved
here, eg user initiates connection to a chat server (via internet), where
the server routes the messages (I think you gurus know what I mean).

Thanks.
Re: PHP socket and NAT [message #177144 is a reply to message #177140] Thu, 23 February 2012 17:28 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Captain Paralytic)

> On Feb 23, 1:53 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> Captain Paralytic wrote:
>>
>>> No they don't, the local network will not allow it. They will have
>>> different IP addresses.
>>
>> They do as far as the outside world is concerned.
>>
> But that is as far as the outside world is concerned. They will still
> not have the same IP addresses.

Inside the LAN, correct. But from the outside only the router's IP
address is visible, and that is the same for all that are behind it.

Micha

--
http://mfesser.de/blickwinkel
Re: PHP socket and NAT [message #177147 is a reply to message #177140] Thu, 23 February 2012 20:42 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Captain Paralytic wrote:
> On Feb 23, 1:53 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> Captain Paralytic wrote:
>>> On Feb 23, 1:09 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>>>> > I'm assuming you're talking about talking to two people on a remote
>>>> > LAN, and that LAN uses NAT to connect to the internet.
>>>> > The first question is - who's connecting to whom?
>>>> > If the remote systems are connecting to you, then there's no problem.
>>>> > However, if you are trying to connect to them, there's a lot more work
>>>> > involved. The router must be set up with port forwarding and you have
>>>> > to connect to the correct port to forward to the proper machine.
>>>> > You can find more information in a TCP/IP newsgroup.
>>>> I am thinking of the scenario where I am talking to 2 persons via the
>>>> internet, and these 2 persons are in the same LAN, something like chatting.
>>>> So the problem in my mind is that these 2 persons have the same IP.
>>> No they don't, the local network will not allow it. They will have
>>> different IP addresses.
>> They do as far as the outside world is concerned.
> But that is as far as the outside world is concerned. They will still
> not have the same IP addresses.
>
>> And the network doesn't *disallow* it inside the NAT area either, it
>> simply stops things working for those two machines :-)


> The local network will not allow 2 machines with the same IP address
> to function on it (communication wise)
>

No, nothing disallows anything. It is just that any machine on that
network will not know which of two competing RARP responses to honour.

In short its perfectly possible to have two different MAC addresses tied
to the same IP address BUT other IP machines on that ethernet can't then
tell which one to direct packets to.
Re: PHP socket and NAT [message #177148 is a reply to message #177141] Thu, 23 February 2012 20:44 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
SL wrote:
>> No they don't, the local network will not allow it. They will have
>> different IP addresses.
>
> Sorry, folks. When I say same IP, I mean the external IP.
>
> I am trying to add something to a chat application; a server is involved
> here, eg user initiates connection to a chat server (via internet)

so that is all you need to know. Just add the data to what he is already
downloading.



, where
> the server routes the messages (I think you gurus know what I mean).
>

It sends them into net land back to the clients router.

THAT knows that any response it gets for such and such a port belongs to
the machine that opened the connection.


> Thanks.
>
>
Re: PHP socket and NAT [message #177150 is a reply to message #177138] Fri, 24 February 2012 10:58 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 23.02.2012 14:53, schrieb The Natural Philosopher:
> Captain Paralytic wrote:
>> On Feb 23, 1:09 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>>>> I'm assuming you're talking about talking to two people on a remote
>>>> LAN, and that LAN uses NAT to connect to the internet.
>>>> The first question is - who's connecting to whom?
>>>> If the remote systems are connecting to you, then there's no problem.
>>>> However, if you are trying to connect to them, there's a lot more work
>>>> involved. The router must be set up with port forwarding and you have
>>>> to connect to the correct port to forward to the proper machine.
>>>> You can find more information in a TCP/IP newsgroup.
>>> I am thinking of the scenario where I am talking to 2 persons via the
>>> internet, and these 2 persons are in the same LAN, something like chatting.
>>> So the problem in my mind is that these 2 persons have the same IP.
>
>> No they don't, the local network will not allow it. They will have
>> different IP addresses.
>
> They do as far as the outside world is concerned.
>
> And the network doesn't *disallow* it inside the NAT area either, it simply stops
> things working for those two machines :-)
>
> As anyone who has done it in the olden days of static IP addresses will tell you.
>
> How we sobbed for joy when DHCP on PC's arrived...try managing upwards of 100
> machines on the same LAN..with static IP addresses..

This is easier than setting the dip switches of arcnet NICs to the mac address...

/Str.
Re: PHP socket and NAT [message #177151 is a reply to message #177141] Fri, 24 February 2012 11:07 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 23.02.2012 17:03, schrieb SL:
>> No they don't, the local network will not allow it. They will have
>> different IP addresses.
>
> Sorry, folks. When I say same IP, I mean the external IP.
>
> I am trying to add something to a chat application; a server is involved
> here, eg user initiates connection to a chat server (via internet), where
> the server routes the messages (I think you gurus know what I mean).
>
> Thanks.
>
>

In the case where the clients connect to the server, there is absolutely no problem
with NAT, it is just transparent. The server responds to these connections like to
any other. Remember: HTTP establishes a TCP connection, and here the endpoints (=
sockets) are identified by ip-address and port number: IP address in the IP header,
port number in the TCP header.

A problem with NAT is to start a connection from the internet to a station on the LAN
through the NAT router. Many call this problem a security feature.

/Str.
Re: PHP socket and NAT [message #177154 is a reply to message #177151] Fri, 24 February 2012 13:22 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
M. Strobel wrote:
> Am 23.02.2012 17:03, schrieb SL:
>>> No they don't, the local network will not allow it. They will have
>>> different IP addresses.
>> Sorry, folks. When I say same IP, I mean the external IP.
>>
>> I am trying to add something to a chat application; a server is involved
>> here, eg user initiates connection to a chat server (via internet), where
>> the server routes the messages (I think you gurus know what I mean).
>>
>> Thanks.
>>
>>
>
> In the case where the clients connect to the server, there is absolutely no problem
> with NAT, it is just transparent. The server responds to these connections like to
> any other. Remember: HTTP establishes a TCP connection, and here the endpoints (=
> sockets) are identified by ip-address and port number: IP address in the IP header,
> port number in the TCP header.
>
> A problem with NAT is to start a connection from the internet to a station on the LAN
> through the NAT router. Many call this problem a security feature.
>

Probably because that is exactly what it is.

All arising out of the perception that SEVERS need connections but
DESKTOPS only make them.

Plus a global shortage of IP addresses...

> /Str.
Re: PHP socket and NAT [message #177159 is a reply to message #177154] Fri, 24 February 2012 14:20 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <ji82v9$jsa$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> M. Strobel wrote:
>> Am 23.02.2012 17:03, schrieb SL:
>>>> No they don't, the local network will not allow it. They will have
>>>> different IP addresses.
>>> Sorry, folks. When I say same IP, I mean the external IP.
>>>
>>> I am trying to add something to a chat application; a server is involved
>>> here, eg user initiates connection to a chat server (via internet), where
>>> the server routes the messages (I think you gurus know what I mean).
>>>
>>> Thanks.
>>>
>>>
>>
>> In the case where the clients connect to the server, there is absolutely no
>> problem
>> with NAT, it is just transparent. The server responds to these connections
>> like to
>> any other. Remember: HTTP establishes a TCP connection, and here the
>> endpoints (=
>> sockets) are identified by ip-address and port number: IP address in the IP
>> header,
>> port number in the TCP header.
>>
>> A problem with NAT is to start a connection from the internet to a station
>> on the LAN
>> through the NAT router. Many call this problem a security feature.
>>
>
> Probably because that is exactly what it is.
>
> All arising out of the perception that SEVERS need connections but
> DESKTOPS only make them.
>
> Plus a global shortage of IP addresses...

Until v6 at any rate - not that you hear ISPs talking about that.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP socket and NAT [message #177164 is a reply to message #177159] Fri, 24 February 2012 15:39 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim Streater wrote:
> In article <ji82v9$jsa$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> M. Strobel wrote:
>>> Am 23.02.2012 17:03, schrieb SL:
>>>> > No they don't, the local network will not allow it. They will have
>>>> > different IP addresses.
>>>> Sorry, folks. When I say same IP, I mean the external IP.
>>>>
>>>> I am trying to add something to a chat application; a server is
>> involved >> here, eg user initiates connection to a chat server (via
>> internet), where >> the server routes the messages (I think you gurus
>> know what I mean).
>>>>
>>>> Thanks. >>
>>>>
>>>> In the case where the clients connect to the server, there is
>> absolutely no > problem
>>> with NAT, it is just transparent. The server responds to these
>> connections > like to
>>> any other. Remember: HTTP establishes a TCP connection, and here the
>>> endpoints (=
>>> sockets) are identified by ip-address and port number: IP address in
>> the IP > header,
>>> port number in the TCP header.
>>>> A problem with NAT is to start a connection from the internet to a
>> station > on the LAN
>>> through the NAT router. Many call this problem a security feature.
>>>
>> Probably because that is exactly what it is.
>>
>> All arising out of the perception that SEVERS need connections but
>> DESKTOPS only make them.
>>
>> Plus a global shortage of IP addresses...
>
> Until v6 at any rate - not that you hear ISPs talking about that.
>
You do, but *quietly*.

There are not a few IPV6 machines out there.
Re: PHP socket and NAT [message #177173 is a reply to message #177164] Fri, 24 February 2012 18:53 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <ji8aun$5et$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:
>> In article <ji82v9$jsa$2(at)news(dot)albasani(dot)net>,
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>>> M. Strobel wrote:
>>>> Am 23.02.2012 17:03, schrieb SL:
>>>> >> No they don't, the local network will not allow it. They will have
>>>> >> different IP addresses.
>>>> > Sorry, folks. When I say same IP, I mean the external IP.
>>>> >
>>>> > I am trying to add something to a chat application; a server is
>>> involved >> here, eg user initiates connection to a chat server (via
>>> internet), where >> the server routes the messages (I think you gurus
>>> know what I mean).
>>>> >
>>>> > Thanks. >>
>>>> >
>>>> > In the case where the clients connect to the server, there is
>>> absolutely no > problem
>>>> with NAT, it is just transparent. The server responds to these
>>> connections > like to
>>>> any other. Remember: HTTP establishes a TCP connection, and here the
>>>> endpoints (=
>>>> sockets) are identified by ip-address and port number: IP address in
>>> the IP > header,
>>>> port number in the TCP header.
>>>> > A problem with NAT is to start a connection from the internet to a
>>> station > on the LAN
>>>> through the NAT router. Many call this problem a security feature.
>>>>
>>> Probably because that is exactly what it is.
>>>
>>> All arising out of the perception that SEVERS need connections but
>>> DESKTOPS only make them.
>>>
>>> Plus a global shortage of IP addresses...
>>
>> Until v6 at any rate - not that you hear ISPs talking about that.
>>
> You do, but *quietly*.
>
> There are not a few IPV6 machines out there.

True, and the Europe-wide network we put together at my last job was all
dual-stack. But trying to get native v6 connections from commodity IP
providers such as COLT, Telia, Sprint, etc, was met with the equivalent
of "Not much call for that round here, Squire!". Mind you that was in
2008 and earlier, it may have improved since then. The fact that the
last /8 blocks have now been handed out may concentrate their minds a
bit.

We'll need new ADSL routers or hopefully just firmware upgrades, though.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP socket and NAT [message #177175 is a reply to message #177173] Fri, 24 February 2012 21:04 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim Streater wrote:
> In article <ji8aun$5et$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim Streater wrote:
>>> In article <ji82v9$jsa$2(at)news(dot)albasani(dot)net>,
>>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> > M. Strobel wrote:
>>>> > Am 23.02.2012 17:03, schrieb SL:
>>>> >>> No they don't, the local network will not allow it. They will have
>>>> >>> different IP addresses.
>>>> >> Sorry, folks. When I say same IP, I mean the external IP.
>>>> >>
>>>> >> I am trying to add something to a chat application; a server is
>>>> involved >> here, eg user initiates connection to a chat server
>> (via >> internet), where >> the server routes the messages (I think
>> you gurus >> know what I mean).
>>>> >>
>>>> >> Thanks. >>
>>>> >>
>>>> > > In the case where the clients connect to the server, there is
>>>> absolutely no > problem
>>>> > with NAT, it is just transparent. The server responds to these >>
>> connections > like to
>>>> > any other. Remember: HTTP establishes a TCP connection, and here
>> the >> > endpoints (=
>>>> > sockets) are identified by ip-address and port number: IP address
>> in >> the IP > header,
>>>> > port number in the TCP header.
>>>> > > A problem with NAT is to start a connection from the internet
>> to a >> station > on the LAN
>>>> > through the NAT router. Many call this problem a security feature.
>>>> >
>>>> Probably because that is exactly what it is.
>>>>
>>>> All arising out of the perception that SEVERS need connections but
>>>> DESKTOPS only make them.
>>>>
>>>> Plus a global shortage of IP addresses...
>>>> Until v6 at any rate - not that you hear ISPs talking about that.
>>> You do, but *quietly*.
>>
>> There are not a few IPV6 machines out there.
>
> True, and the Europe-wide network we put together at my last job was all
> dual-stack. But trying to get native v6 connections from commodity IP
> providers such as COLT, Telia, Sprint, etc, was met with the equivalent
> of "Not much call for that round here, Squire!". Mind you that was in
> 2008 and earlier, it may have improved since then. The fact that the
> last /8 blocks have now been handed out may concentrate their minds a bit.
>
There's a lot of action on it..most new machines can handle the stack
and the rest of it..many but not all ISPs are routing it.

Its a bit like digital telly. When that started you had to get a sky
dish, then you COULD bolt a set top box on the side, now its de rigeur..

I would say we will all be IPv6 within 10 years except a few islands
behind NAT firewalls


> We'll need new ADSL routers or hopefully just firmware upgrades, though.
>

Not sure. I think a lot of DNS things will return IPV6 stuff
already..the core internet is offering it in parallel.
Re: PHP socket and NAT [message #177178 is a reply to message #177175] Fri, 24 February 2012 21:41 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <ji8u1p$f4n$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:

>> We'll need new ADSL routers or hopefully just firmware upgrades, though.
>
> Not sure. I think a lot of DNS things will return IPV6 stuff
> already..the core internet is offering it in parallel.

Actually even my DG834 is a linux box so I imagine its all there really,
just needs turning on. But there's nothing in any of the displays about
it.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP socket and NAT [message #177197 is a reply to message #177173] Sun, 26 February 2012 18:50 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Fri, 24 Feb 2012 18:53:36 +0000, Tim Streater wrote:
> True, and the Europe-wide network we put together at my last job was all
> dual-stack. But trying to get native v6 connections from commodity IP
> providers such as COLT, Telia, Sprint, etc, was met with the equivalent
> of "Not much call for that round here, Squire!". Mind you that was in
> 2008 and earlier, it may have improved since then.

Nope. Hasn't.

> The fact that the last /8 blocks have now been handed out may
> concentrate their minds a bit.
>
> We'll need new ADSL routers or hopefully just firmware upgrades,
> though.

More likely to get routers that can handle much larger state tables for
v4 routing instead. (; The "worldwide shortage of IP addresses" fails to
account for that big enough state tables can put 10.*.*.* behind every
enpoint IP addess out there, especially if most of the traffic is
internal anyway.

--
For every subject you can think of there are at least 3 web sites.
The owners of these web sites know each other and at least one of
them hates at least one of the others.
-- mnlooney's view of Skif's Internet Theorem
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: chat on web, Ajax ?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 18:49:16 GMT 2024

Total time taken to generate the page: 0.03484 seconds