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
Return to the default flat view Create a new topic Submit Reply
Re: PHP socket and NAT [message #177137 is a reply to message #177128] Thu, 23 February 2012 13:50 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
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.
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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 Dec 01 05:29:47 GMT 2024

Total time taken to generate the page: 0.06360 seconds