NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Wolfgang Orth on July 03, 2011, 01:11:30 PM
-
Hello all and Bruce,
a while ago I wrote a Simple-client-simple-server-combo that kept the connection open by sending signals back and forth to trick the time-out. It was sort of Long Polling.
Now I would like to re-write that combo, but as a webserver. There will be several webclients that will keep connection with the server as in the previous project with the simple-server/client.
Two questions ar on my mind:
Where / in which embed/method do I collect and store the IP-Addresses of the clients? I tested several embed, learned that .MakePage gets triggered only one time. Other embeds get hit more often, but actualy it doesn't matter that much as I could eliminate duplicate entries. I'd just like to know the "legal" one, not one that just works accidently ;-)
The other question: where to store? My idea is to use an IMDD-file.
I understood so far, that each request is processed by the server in a separate thread. That would mean, if 3 clients connect to the server, I get 3 tables with just one record, and as the thread ends within a second, each table is gone after that peticular second.
During my tests so far I played with a global queue. This one seems to be persistent.
And a third question came to my mind: in the simple-combo I stored the socket and sock-id, beside the IP. I guess the webserver handles and hides socket/sock-id from me, so I would simply send data back to the raw IP-Address?
I am curios how it would work with proxies. But first I have to get it going.....
Thanks for any input,
Wolfgang
-
Sorry Wolfgang, it's not gonna work for you. The WebHandler closes the connection once the reply is sent. It has nothing to do with a timeout, that's just how it works. To make it work you'd need to keep the WebHandler thread alive. But it wouldn't receive further incoming packets from the client - it's just not set up to do that.
Best embed to detect the IP address is WebHandler, ProcessLink, Before parent call. There's a method called p_web.GetSessionIP()
>> The other question: where to store? My idea is to use an IMDD-file.
yes.
>> During my tests so far I played with a global queue.
no, this is not thread-safe (unless you explicitly make it so).
>> I understood so far, that each request is processed by the server in a separate thread. That would mean, if 3 clients connect to the server, I get 3 tables with just one record,
No, while you can _make_ IMDD behave like this, it does not behave like this by default. Default behaviour is that you'd get 1 file with 3 records.
Cheers
Bruce
-
hmmmm, too bad .....
The existing server works pretty well, but I'd like it to communictae on port 80 like all other (web)server here. But unfortunately I can't integrate a simpleserver into my Apache vhost-setting.
re: getting the IP-Address - in .MakePage I assigned the variable with the value from .GetSessionIP()
why making it easy while you can make it complicated <g>
Thanks for your response, Bruce!