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

Home » Imported messages » comp.lang.php » chat on web, Ajax ?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
chat on web, Ajax ? [message #177157] Fri, 24 February 2012 13:59 Go to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
Hi folks.

I thought I have gathered all pieces I need, then suddenly I realise there
is still one problem.

I am implementing chat on the web, ie on a browse. On browser, I can only
use javascript. So the problem is what method to use to listen for incoming
data.

Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
the standard method is "open socket at server, port 8888...".

Of course, when data is sent to a php file on server, it must be port 80.

Is this the only way on a browser ?

Thanks.
Re: chat on web, Ajax ? [message #177158 is a reply to message #177157] Fri, 24 February 2012 14:15 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
> I thought I have gathered all pieces I need, then suddenly I realise
> there is still one problem.
>
> I am implementing chat on the web, ie on a browse. On browser, I can
> only use javascript. So the problem is what method to use to listen
> for incoming data.
>
> Ajax ? I am just wondering; Ajax does not seem to bother about port,
> I mean the standard method is "open socket at server, port 8888...".
>
> Of course, when data is sent to a php file on server, it must be port
> 80.
> Is this the only way on a browser ?
>

After reading some material, it seems that a timer (for Ajax) is necessary
to pool the server for messages.

With java or C/C++, there is no timer, ie a client just listens on a socket,
and it is notified once data is in. Correct me if I am wrong (ie the client
does not pool the server in this case).
Re: chat on web, Ajax ? [message #177160 is a reply to message #177158] Fri, 24 February 2012 14:20 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 24, 2:15 pm, "sl@exabyte" <sb5...@hotmail.com> wrote:
>> I thought I have gathered all pieces I need, then suddenly I realise
>> there is still one problem.
>
>> I am implementing chat on the web, ie on a browse. On browser, I can
>> only use javascript. So the problem is what method to use to listen
>> for incoming data.
>
>> Ajax ? I am just wondering; Ajax does not seem to bother about port,
>> I mean the standard method is "open socket at server, port 8888...".
>
>> Of course, when data is sent to a php file on server, it must be port
>> 80.
>> Is this the only way on a browser ?
>
> After reading some material, it seems that a timer (for Ajax) is necessary
> to pool the server for messages.
>
> With java or C/C++, there is no timer, ie a client just listens on a socket,
> and it is notified once data is in. Correct me if I am wrong (ie the client
> does not pool the server in this case).

One has to ask, since there are so many already available free to
download, just why are you writing yet another one?
Re: chat on web, Ajax ? [message #177161 is a reply to message #177157] Fri, 24 February 2012 14:28 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/24/2012 2:59 PM, sl@exabyte wrote:
> Hi folks.

Hi again,


>
> I thought I have gathered all pieces I need, then suddenly I realise there
> is still one problem.

Some of us guessed by reading your former thread. :-)


>
> I am implementing chat on the web, ie on a browse. On browser, I can only
> use javascript. So the problem is what method to use to listen for incoming
> data.

Yes.
That is the problem: typical http requests data from some server, and
after it arrives, that's it.
A normal http request:
1) Browser sends request to server.
2) server answers
the end.
How to let the browser listen to the server?

Short answer: You cannot. Not without some tricks or additional software
(Java, Flash for example).

Read up here first:
http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push

You can see on that page that a few experiments have been tried, but
none of them if fully reliable.
For example: multipart/x-mixed-replace is not supported by IE, and I
don't know about mobile devices.

You have 2 options:
1) Make a client-pull approach, eg with XHR ("Ajax").
http://en.wikipedia.org/wiki/XMLHttpRequest
Advantage: Easy to implement.
Drawback: All the connected clients will be sending update-requests all
the time. This will lead to extra serverload which can kill the server
if you have many clients trying to chat.

2) Use additional software that CAN listen.
Problem: See former thread: Suppose your server wants to PUSH new data
to some client: How to deliver that behind a firewall/NAT? To which port?

Maybe IP6 and UPNP can help you out? I am not sure to be honest.
http://en.wikipedia.org/wiki/UPNP
UPNP can help you out of the NAT mess, but it isn't supported everywhere
(I disabled it because I don't want programs to open ports on my router.)

I once created a chat application, and resorted to PULL technology
because of all the problems. In my situation that was OK because the
load was low, and the approach worked (This was before the XHR days, and
I used a hidden frame and Javascript to pull the trick.)

Bottomline: Decide if you want to go CLIENT-PULL (easy, but limited) or
SERVER-PUSH (Hard).

But you better go to a networking group instead of this one.
These advanced networking protocols (both IP6 and UPNP) are quite
complex, and this isn't PHP related.

Regards,
Erwin Moller

>
> Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
> the standard method is "open socket at server, port 8888...".
>
> Of course, when data is sent to a php file on server, it must be port 80.
>
> Is this the only way on a browser ?
>
> Thanks.
>
>




--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: chat on web, Ajax ? [message #177162 is a reply to message #177161] Fri, 24 February 2012 14:51 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 <4f479e77$0$6860$e4fe514c(at)news2(dot)news(dot)xs4all(dot)nl>,
Erwin Moller <erwinmollerusenet(at)xs4all(dot)nl> wrote:

> On 2/24/2012 2:59 PM, sl@exabyte wrote:

>> I am implementing chat on the web, ie on a browse. On browser, I can only
>> use javascript. So the problem is what method to use to listen for incoming
>> data.
>
> Yes.
> That is the problem: typical http requests data from some server, and
> after it arrives, that's it.
> A normal http request:
> 1) Browser sends request to server.
> 2) server answers
> the end.
> How to let the browser listen to the server?
>
> Short answer: You cannot. Not without some tricks or additional software
> (Java, Flash for example).
>
> Read up here first:
> http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
>
> You can see on that page that a few experiments have been tried, but
> none of them if fully reliable.
> For example: multipart/x-mixed-replace is not supported by IE, and I
> don't know about mobile devices.
>
> You have 2 options:
> 1) Make a client-pull approach, eg with XHR ("Ajax").
> http://en.wikipedia.org/wiki/XMLHttpRequest
> Advantage: Easy to implement.
> Drawback: All the connected clients will be sending update-requests all
> the time. This will lead to extra serverload which can kill the server
> if you have many clients trying to chat.
>
> 2) Use additional software that CAN listen.
> Problem: See former thread: Suppose your server wants to PUSH new data
> to some client: How to deliver that behind a firewall/NAT? To which port?
>
> Maybe IP6 and UPNP can help you out? I am not sure to be honest.
> http://en.wikipedia.org/wiki/UPNP
> UPNP can help you out of the NAT mess, but it isn't supported everywhere
> (I disabled it because I don't want programs to open ports on my router.)
>
> I once created a chat application, and resorted to PULL technology
> because of all the problems. In my situation that was OK because the
> load was low, and the approach worked (This was before the XHR days, and
> I used a hidden frame and Javascript to pull the trick.)
>
> Bottomline: Decide if you want to go CLIENT-PULL (easy, but limited) or
> SERVER-PUSH (Hard).
>
> But you better go to a networking group instead of this one.
> These advanced networking protocols (both IP6 and UPNP) are quite
> complex, and this isn't PHP related.

Or you can wait until websockets is more widely available - see RFC 6455:

<http://tools.ietf.org/html/rfc6455>

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177163 is a reply to message #177158] Fri, 24 February 2012 15:22 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 24.02.2012 15:15, schrieb sl@exabyte:
>> I thought I have gathered all pieces I need, then suddenly I realise
>> there is still one problem.
>>
>> I am implementing chat on the web, ie on a browse. On browser, I can
>> only use javascript. So the problem is what method to use to listen
>> for incoming data.
>>
>> Ajax ? I am just wondering; Ajax does not seem to bother about port,
>> I mean the standard method is "open socket at server, port 8888...".
>>
>> Of course, when data is sent to a php file on server, it must be port
>> 80.
>> Is this the only way on a browser ?
>>
>
> After reading some material, it seems that a timer (for Ajax) is necessary
> to pool the server for messages.
>
> With java or C/C++, there is no timer, ie a client just listens on a socket,
> and it is notified once data is in. Correct me if I am wrong (ie the client
> does not pool the server in this case).
>
>

Replace "pool" by "poll" - a distorting typo...

/Str.
Re: chat on web, Ajax ? [message #177165 is a reply to message #177157] Fri, 24 February 2012 15:48 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:
> Hi folks.
>
> I thought I have gathered all pieces I need, then suddenly I realise there
> is still one problem.
>
> I am implementing chat on the web, ie on a browse. On browser, I can only
> use javascript.
You coudl poll the server using a whole page or a framethereof.

Thats all javascript does, but it does it a bit more efficiently.

So the problem is what method to use to listen for incoming
> data.
>
> Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
> the standard method is "open socket at server, port 8888...".
>
so?
> Of course, when data is sent to a php file on server, it must be port 80.
>

not always.

Yiu can specify any port you want in a url.

General form of url is

"Http:" - the protocol to use
"Mywebserverg.org" a resolvable dns location on the internet.
"/mydirectory.myfile.ext" where on the server teh file is (virtually)
located and some hints in ext as to how the file is to be processed
before being sent
"?param=value&param2=valeu2..." GET variables to be passed to the script
if any
":port number" the port to connect to at the remote end.


So you can set up a web server on any port you like and access it with a
special URL.


> Is this the only way on a browser ?
>

All methods are essentially polling and client initiated. The
differences lie in what mechanism you use to poll, and how much of the
page or frame you download.

So at the crudest end a meta refresh tag will reload the whole page, or
a frame within a page. A javsacript reload can do te same, but it can
request and even smaller block of data and rebuild part of te page with it.

Ajax is just a way of doing that with a bit less overhead IIRC.

All can be vectored to any server port you like.

> Thanks.
>
>
Re: chat on web, Ajax ? [message #177166 is a reply to message #177160] Fri, 24 February 2012 15:52 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
> One has to ask, since there are so many already available free to
> download, just why are you writing yet another one?

Sometimes history repeats. You see I trying to add other things to a chat,
partly experimenting. So the first part is to learn.
Only after acquring the basics that I can move on.

Come to think of it, in school wheels often get re-invented. Of course there
is no need to re-invent the steam engine. :-)
Re: chat on web, Ajax ? [message #177167 is a reply to message #177162] Fri, 24 February 2012 15:54 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:

>
> Or you can wait until websockets is more widely available - see RFC 6455:
>
> <http://tools.ietf.org/html/rfc6455>
>

Now that was worth a mention Tim.

Its an implementation the world badly needs, to do 'cloud' based' stuff.

In your OPPINION when is it likely to be something that apache and most
browsers understand..or is it even a browser issue at all?
..
Re: chat on web, Ajax ? [message #177168 is a reply to message #177166] Fri, 24 February 2012 15:59 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:
>> One has to ask, since there are so many already available free to
>> download, just why are you writing yet another one?
>
> Sometimes history repeats. You see I trying to add other things to a chat,
> partly experimenting. So the first part is to learn.
> Only after acquring the basics that I can move on.
>
> Come to think of it, in school wheels often get re-invented. Of course there
> is no need to re-invent the steam engine. :-)
>
>
Absolutely. I spent some time earlier this week writing a C library
that will do a simple SMTP send.. Why? because it took less time that
trying to actually work out how to use one of the many libraries..

And I wanted the fastest slimmest code to run under cron..
Re: chat on web, Ajax ? [message #177169 is a reply to message #177168] Fri, 24 February 2012 16:23 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
> Absolutely. I spent some time earlier this week writing a C library
> that will do a simple SMTP send.. Why? because it took less time that
> trying to actually work out how to use one of the many libraries..
>
> And I wanted the fastest slimmest code to run under cron..

Wow, that sounds interesting.

The one thing now I wish to dig deep is Linux and programming. I wish I have
48 hours a day.

I heard that if we live in neptune, a year there is 165 years here.
Re: chat on web, Ajax ? [message #177170 is a reply to message #177157] Fri, 24 February 2012 16:27 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
sl@exabyte wrote:

> I am implementing chat on the web, ie on a browse. On browser, I can only
> use javascript. So the problem is what method to use to listen for
> incoming data.

The most compatible approach is to poll the server for new messages
regularly. How to do that is on-topic in comp.lang.javascript. Useful
answers on Usenet are more likely if you post under your real name.

> Ajax ? I am just wondering; Ajax does not seem to bother about port,

You are mistaken. BTW, "Ajax" is a misnomer; thinking "XMLHttpRequest"
instead will get you further.

> I mean the standard method is "open socket at server, port 8888...".

No, it is not.

> Of course, when data is sent to a php file on server, it must be port 80.

No, it does not have to.

> Is this the only way on a browser ?

There is also the Comet approach, and there are Web Sockets. However, the
latter has security issues and is not well supported as of yet.

Your problem in general is on-topic in comp.infosystems.www.authoring.misc,
not here. You should have known already as you noticed that this cannot be
solved with PHP alone. Please adhere to the topic-oriented structuring of
Network News, and Usenet in particular. And please do not start new threads
for old problems.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Re: chat on web, Ajax ? [message #177171 is a reply to message #177161] Fri, 24 February 2012 16:31 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
> That is the problem: typical http requests data from some server, and
> after it arrives, that's it.
> A normal http request:
> 1) Browser sends request to server.
> 2) server answers
> the end.
> How to let the browser listen to the server?
>
> Short answer: You cannot. Not without some tricks or additional
> software (Java, Flash for example).
>
> Read up here first:
> http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
>
> You can see on that page that a few experiments have been tried, but
> none of them if fully reliable.
> For example: multipart/x-mixed-replace is not supported by IE, and I
> don't know about mobile devices.
>
> You have 2 options:
> 1) Make a client-pull approach, eg with XHR ("Ajax").
> http://en.wikipedia.org/wiki/XMLHttpRequest
> Advantage: Easy to implement.
> Drawback: All the connected clients will be sending update-requests
> all the time. This will lead to extra serverload which can kill the
> server if you have many clients trying to chat.
>
> 2) Use additional software that CAN listen.
> Problem: See former thread: Suppose your server wants to PUSH new data
> to some client: How to deliver that behind a firewall/NAT? To which
> port?
.....
.....

Yahoo has a messenger that is implemented on web; one can see it after
logging in to check mail.

With such serious shortcomings, I suppose they have to have a larger server
farm to take care of the load from chatting.

:-) :-)
Re: chat on web, Ajax ? [message #177172 is a reply to message #177169] Fri, 24 February 2012 16:52 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
"SL" <sb5309(at)hotmail(dot)com> wrote in news:ji8dih$bm8$1(at)news(dot)albasani(dot)net:

>
> I heard that if we live in neptune, a year there is 165 years here.

Just means you'll die at age 1/2.
Re: chat on web, Ajax ? [message #177174 is a reply to message #177167] Fri, 24 February 2012 19:02 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 <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:
>
>> Or you can wait until websockets is more widely available - see RFC 6455:
>>
>> <http://tools.ietf.org/html/rfc6455>
>
> Now that was worth a mention Tim.
>
> Its an implementation the world badly needs, to do 'cloud' based' stuff.
>
> In your OPINION when is it likely to be something that apache and most
> browsers understand..or is it even a browser issue at all?

Apache doesn't need to be involved, the browser can use it to
communicate with any listening software. There've been a couple of
iterations of the websockets handshake but looks now like its been
finalised so we can hope that browsers soon implement the final spec.

Last year I was testing it for use with my email client, Safari 5.1
implements it and I was able to find a listener (several in fact)
written in PHP. I want this since at present I'm using AJAX to an
instance of apache, but that's way too heavy for the app's actual needs.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177176 is a reply to message #177174] Fri, 24 February 2012 21:06 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 <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim Streater wrote:
>>
>>> Or you can wait until websockets is more widely available - see RFC
>> 6455:
>>>> <http://tools.ietf.org/html/rfc6455>
>>
>> Now that was worth a mention Tim.
>>
>> Its an implementation the world badly needs, to do 'cloud' based' stuff.
>>
>> In your OPINION when is it likely to be something that apache and
>> most browsers understand..or is it even a browser issue at all?
>
> Apache doesn't need to be involved, the browser can use it to
> communicate with any listening software. There've been a couple of
> iterations of the websockets handshake but looks now like its been
> finalised so we can hope that browsers soon implement the final spec.
>
> Last year I was testing it for use with my email client, Safari 5.1
> implements it and I was able to find a listener (several in fact)
> written in PHP. I want this since at present I'm using AJAX to an
> instance of apache, but that's way too heavy for the app's actual needs.
>

Great. But I suspect its going to be another massive security hole
opened up ...:-(
Re: chat on web, Ajax ? [message #177177 is a reply to message #177176] Fri, 24 February 2012 21:38 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 <ji8u4c$f4n$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:
>> In article <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>>> Tim Streater wrote:
>>>
>>>> Or you can wait until websockets is more widely available - see RFC
>>> 6455:
>>>> > <http://tools.ietf.org/html/rfc6455>
>>>
>>> Now that was worth a mention Tim.
>>>
>>> Its an implementation the world badly needs, to do 'cloud' based' stuff.
>>>
>>> In your OPINION when is it likely to be something that apache and
>>> most browsers understand..or is it even a browser issue at all?
>>
>> Apache doesn't need to be involved, the browser can use it to
>> communicate with any listening software. There've been a couple of
>> iterations of the websockets handshake but looks now like its been
>> finalised so we can hope that browsers soon implement the final spec.
>>
>> Last year I was testing it for use with my email client, Safari 5.1
>> implements it and I was able to find a listener (several in fact)
>> written in PHP. I want this since at present I'm using AJAX to an
>> instance of apache, but that's way too heavy for the app's actual needs.
>
> Great. But I suspect its going to be another massive security hole
> opened up ...:-(

Perhaps. In my case its all within localhost.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177179 is a reply to message #177177] Fri, 24 February 2012 21:51 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 <ji8u4c$f4n$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim Streater wrote:
>>> In article <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
>>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> > Tim Streater wrote:
>>>>
>>>> > Or you can wait until websockets is more widely available - see
>> RFC >> 6455:
>>>> > > <http://tools.ietf.org/html/rfc6455>
>>>>
>>>> Now that was worth a mention Tim.
>>>>
>>>> Its an implementation the world badly needs, to do 'cloud' based'
>> stuff.
>>>>
>>>> In your OPINION when is it likely to be something that apache and
>>>> most browsers understand..or is it even a browser issue at all?
>>>> Apache doesn't need to be involved, the browser can use it to >
>> communicate with any listening software. There've been a couple of >
>> iterations of the websockets handshake but looks now like its been >
>> finalised so we can hope that browsers soon implement the final spec.
>>>> Last year I was testing it for use with my email client, Safari
>> 5.1 > implements it and I was able to find a listener (several in
>> fact) > written in PHP. I want this since at present I'm using AJAX to
>> an > instance of apache, but that's way too heavy for the app's actual
>> needs.
>>
>> Great. But I suspect its going to be another massive security hole
>> opened up ...:-(
>
> Perhaps. In my case its all within localhost.
>
yes. The app I may use this on is all within my LAN.


Its seems firefox 10.0.2 is quite happy to websocket away.

Just needs a daemon for the server...inetd? yep that'll do..and a leetle
teensy bit of code to be invoked by it.

Got any serverside cribs

All I found was this..

http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/s erver.php
?
Re: chat on web, Ajax ? [message #177180 is a reply to message #177179] Fri, 24 February 2012 22:26 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 <ji90od$k49$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:
>> In article <ji8u4c$f4n$2(at)news(dot)albasani(dot)net>,
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>>> Tim Streater wrote:
>>>> In article <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
>>>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> >> Tim Streater wrote:
>>>> >
>>>> > > Or you can wait until websockets is more widely available - see
>>> RFC >> 6455:
>>>> > > > <http://tools.ietf.org/html/rfc6455>
>>>> >
>>>> > Now that was worth a mention Tim.
>>>> >
>>>> > Its an implementation the world badly needs, to do 'cloud' based'
>>> stuff.
>>>> >
>>>> > In your OPINION when is it likely to be something that apache and
>>>> > most browsers understand..or is it even a browser issue at all?
>>>> > Apache doesn't need to be involved, the browser can use it to >
>>> communicate with any listening software. There've been a couple of >
>>> iterations of the websockets handshake but looks now like its been >
>>> finalised so we can hope that browsers soon implement the final spec.
>>>> > Last year I was testing it for use with my email client, Safari
>>> 5.1 > implements it and I was able to find a listener (several in
>>> fact) > written in PHP. I want this since at present I'm using AJAX to
>>> an > instance of apache, but that's way too heavy for the app's actual
>>> needs.
>>>
>>> Great. But I suspect its going to be another massive security hole
>>> opened up ...:-(
>>
>> Perhaps. In my case its all within localhost.
>>
> yes. The app I may use this on is all within my LAN.
>
> Its seems firefox 10.0.2 is quite happy to websocket away.
>
> Just needs a daemon for the server...inetd? yep that'll do..and a leetle
> teensy bit of code to be invoked by it.
>
> Got any serverside cribs
>
> All I found was this..
>
> http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/s erv
> er.php
> ?

Could start here:

<http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations>

I did some tests with this one:

<https://github.com/jam1401>

I also found something called daemonize that allows me to write a daemon
as a PHP script but have it run as a proper background daemon.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177181 is a reply to message #177172] Sat, 25 February 2012 02:01 Go to previous messageGo to next message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma: 0
Junior Member
>>
>> I heard that if we live in neptune, a year there is 165 years here.
>
> Just means you'll die at age 1/2.

This is off topic.

Time is very special, they say relative. There is a possibility that if a
day (assumed) has 48 hours, that is the sun sets after 24 hours, our body
will adjust to it. Meaning the body adjusts to a year, ie setting of the sun
is 24 hours.

While human being still lives 90 years, but relative to the Earth, the time
span is different.
Re: chat on web, Ajax ? [message #177184 is a reply to message #177180] Sat, 25 February 2012 13:15 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 <ji90od$k49$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim Streater wrote:
>>> In article <ji8u4c$f4n$2(at)news(dot)albasani(dot)net>,
>>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> > Tim Streater wrote:
>>>> > In article <ji8brm$6k0$2(at)news(dot)albasani(dot)net>,
>>>> > The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> > >> Tim Streater wrote:
>>>> >>
>>>> >> > Or you can wait until websockets is more widely available -
>> see >> RFC >> 6455:
>>>> >> > > <http://tools.ietf.org/html/rfc6455>
>>>> >>
>>>> >> Now that was worth a mention Tim.
>>>> >>
>>>> >> Its an implementation the world badly needs, to do 'cloud'
>> based' >> stuff.
>>>> >>
>>>> >> In your OPINION when is it likely to be something that apache
>> and >> >> most browsers understand..or is it even a browser issue at
>> all?
>>>> > > Apache doesn't need to be involved, the browser can use it to >
>>>> communicate with any listening software. There've been a couple of
>>>> > iterations of the websockets handshake but looks now like its
>> been > >> finalised so we can hope that browsers soon implement the
>> final spec.
>>>> > > Last year I was testing it for use with my email client, Safari
>>>> 5.1 > implements it and I was able to find a listener (several in
>>>> fact) > written in PHP. I want this since at present I'm using AJAX
>> to >> an > instance of apache, but that's way too heavy for the app's
>> actual >> needs.
>>>>
>>>> Great. But I suspect its going to be another massive security hole
>>>> opened up ...:-(
>>>> Perhaps. In my case its all within localhost.
>>> yes. The app I may use this on is all within my LAN.
>>
>> Its seems firefox 10.0.2 is quite happy to websocket away.
>>
>> Just needs a daemon for the server...inetd? yep that'll do..and a
>> leetle teensy bit of code to be invoked by it.
>>
>> Got any serverside cribs
>>
>> All I found was this..
>>
>> http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/s erv
>>
>> er.php
>> ?
>
> Could start here:
>
> <http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations>
>
> I did some tests with this one:
>
> <https://github.com/jam1401>
>

that's worth a look..

> I also found something called daemonize that allows me to write a daemon
> as a PHP script but have it run as a proper background daemon.
>

well you can always attach a script to inetd..for low volume use.

And a C style daemon is not the worst programming job in the world..

I've been mixing C and PHP recently, and to be honest there is not a
great deal of difference in coding time. And once you have a makefile
source->binary for small projects is not much slower than saving a php
file :-)
Re: chat on web, Ajax ? [message #177185 is a reply to message #177157] Sat, 25 February 2012 13:13 Go to previous messageGo to next message
Jeff North is currently offline  Jeff North
Messages: 58
Registered: November 2010
Karma: 0
Member
On Fri, 24 Feb 2012 21:59:07 +0800, in comp.lang.php "sl@exabyte"
<sb5309(at)hotmail(dot)com>
<ji853f$ooi$1(at)news(dot)albasani(dot)net> wrote:

> | Hi folks.
> |
> | I thought I have gathered all pieces I need, then suddenly I realise there
> | is still one problem.
> |
> | I am implementing chat on the web, ie on a browse. On browser, I can only
> | use javascript. So the problem is what method to use to listen for incoming
> | data.
> |
> | Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
> | the standard method is "open socket at server, port 8888...".
> |
> | Of course, when data is sent to a php file on server, it must be port 80.
> |
> | Is this the only way on a browser ?
> |
> | Thanks.
> |

I don't know if this is what you are wanting but have you had a look
at node.js at http://nodejs.org/
Re: chat on web, Ajax ? [message #177186 is a reply to message #177184] Sat, 25 February 2012 13: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 <jiamso$n31$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:

>> I also found something called daemonize that allows me to write a daemon
>> as a PHP script but have it run as a proper background daemon.

> well you can always attach a script to inetd..for low volume use.
>
> And a C style daemon is not the worst programming job in the world..
>
> I've been mixing C and PHP recently, and to be honest there is not a
> great deal of difference in coding time. And once you have a makefile
> source->binary for small projects is not much slower than saving a php
> file :-)

Must be 20 years since I wrote any amount of C. Not sure I could be
arsed to have another go at it (other than small mods to e.g. the
sqlite3 command line tool). I'll stick to PHP, which seems fast enough
for my purposes. Each time I've had a major bottleneck in my email
client I've just rejigged either the PHP or the JavaScript and it's gone
away.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177187 is a reply to message #177186] Sat, 25 February 2012 13:33 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 <jiamso$n31$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim Streater wrote:
>
>>> I also found something called daemonize that allows me to write a
>> daemon > as a PHP script but have it run as a proper background daemon.
>
>> well you can always attach a script to inetd..for low volume use.
>>
>> And a C style daemon is not the worst programming job in the world..
>>
>> I've been mixing C and PHP recently, and to be honest there is not a
>> great deal of difference in coding time. And once you have a makefile
>> source->binary for small projects is not much slower than saving a php
>> file :-)
>
> Must be 20 years since I wrote any amount of C.

well I was feeling like that too. It all came back fairly quickly, and I
realised how much I missed PROPER strong typing..

Not sure I could be
> arsed to have another go at it (other than small mods to e.g. the
> sqlite3 command line tool). I'll stick to PHP, which seems fast enough
> for my purposes. Each time I've had a major bottleneck in my email
> client I've just rejigged either the PHP or the JavaScript and it's gone
> away.
>
Re: chat on web, Ajax ? [message #177188 is a reply to message #177187] Sat, 25 February 2012 13:42 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 <jianvj$pb8$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:
>> In article <jiamso$n31$1(at)news(dot)albasani(dot)net>,
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>>> Tim Streater wrote:
>>
>>>> I also found something called daemonize that allows me to write a
>>> daemon > as a PHP script but have it run as a proper background daemon.
>>
>>> well you can always attach a script to inetd..for low volume use.
>>>
>>> And a C style daemon is not the worst programming job in the world..
>>>
>>> I've been mixing C and PHP recently, and to be honest there is not a
>>> great deal of difference in coding time. And once you have a makefile
>>> source->binary for small projects is not much slower than saving a php
>>> file :-)
>>
>> Must be 20 years since I wrote any amount of C.
>
> well I was feeling like that too. It all came back fairly quickly, and I
> realised how much I missed PROPER strong typing..

:-)

Ha! I don't miss it at all - but then I'm a lazy sod.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: chat on web, Ajax ? [message #177191 is a reply to message #177157] Sun, 26 February 2012 03:54 Go to previous message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
sl@exabyte, 2012-02-24 14:59:

> Hi folks.
>
> I thought I have gathered all pieces I need, then suddenly I realise there
> is still one problem.
>
> I am implementing chat on the web, ie on a browse. On browser, I can only
> use javascript. So the problem is what method to use to listen for incoming
> data.

There is no method. You have to poll every x seconds to check, if there
is new information available. Netscape and Mozilla implemented an
alternative way, but this is neither standard nor recommended to be used.

> Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
> the standard method is "open socket at server, port 8888...".

Did you try <https://blueimp.net/ajax/>?

> Of course, when data is sent to a php file on server, it must be port 80.

Only, if the server is configured to respond on port 80. A web server
can also use other ports.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FastCGI & PHP
Next Topic: PHP socket and NAT
Goto Forum:
  

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

Current Time: Wed Nov 27 01:56:36 GMT 2024

Total time taken to generate the page: 0.02895 seconds