[AOLSERVER] Aolserver as multithreaded TCL socket server ?

17 views
Skip to first unread message

Nikolay Shulga

unread,
Aug 18, 2009, 8:56:06 AM8/18/09
to AOLS...@listserv.aol.com
Hello,

Is it possible to use Aolserver as multithreaded TCL socket server ?

If I connect to Aolserver using telnet , the server waits one of HTTP comands from me. But it would be good to have full access to the socket , from TCL script, without being obliged to send HTTP GET or other requests.

ns_register_proc - unfortunately doesn't give such a possibility, I can have access to the socket but only after HTTP request has been sent.

ns_socklistencallback - it gives full controll over the channell , but process only one client at the moment. It will accept connections from several clients, but will process only the first one. The others will block untill the first one will disconnect.

Please , if anyone knows the solution for this, share it with me .



--

Nikolay Shulga

IT Support
Runway International
Basteja blvd.16, Riga, LV 1050, Latvia
Fax: +371 67 224 439
Mob. :  +371 29 666 501
nikolay...@runway.lv
www.runway.lv

__________________________________

Multi-lingual contact centre services

for the Nordic, European, Russian

and English speaking markets

 

 

 

-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Bas Scheffers

unread,
Aug 18, 2009, 6:57:49 PM8/18/09
to AOLS...@listserv.aol.com
As far as I am aware, the only way to do it is to implement a new socket driver in C.

AOLserver can certainly handle this. There used to be nsftp, which did just that.

Bas.

>

[mailto:nikolay...@runway.lv] nikolay...@runway.lv
>
[http://www.runway.lv/] www.runway.lv

Nikolay Shulga

unread,
Aug 20, 2009, 4:47:22 AM8/20/09
to AOLS...@listserv.aol.com
Hello,

AolServer gives a possibility to use ns_socklistencallback to open a socket, 'ns_thread begindetached' to create thread, ns_chan  - to path channel to this thread. If we do this with every new connection, we get multithreaded tcp socket server - which is exactly what I wanted. I've tested it and it works.

Now I have a question if there exists any potential problem with such aproach ? During this week, I has been googling on this topic. I've met several discussions in the Internet on this theme, and for some strange reason nobody has proposed this method to be used, it has not been discussed. So is there a reason not to use it ?

Nikolay Shulga

 

Jim Davidson

unread,
Aug 20, 2009, 10:31:13 AM8/20/09
to AOLS...@listserv.aol.com
The code should work ok. I remember it was a bit messy to map these Aolserver tcl commands which pre-dated the Tcl channel stuff so it was compatible years ago and there were examples of memory leaks from long running detached tcl threads but with care it should be ok
  

Jim

Sent from my iPhone

Tom Jackson

unread,
Aug 30, 2009, 6:45:33 PM8/30/09
to AOLS...@listserv.aol.com
I thought I sent this last week, but I used the wrong account, anyway:

This example is not "multi-threaded", but it handles multiple
connections. The basic API are ns_socklisten, ns_sockaccept and
ns_sockcheck. (http://rmadilo.com/files/nsapi/)

The example also uses ns_socklistencallback, but the code is very
cryptic. Basically the client contacts the server with a contact
address/port then creates a server to listen for updates (server
push).

The server uses ns_socklistencallback but avoids hanging in a single
thread because it just gets the contact information and starts a
scheduled proc to handle the recurring request (push).

The scheduled proc contacts the client on the given schedule and
pushes the requested data.

The client could actually handle requests from multiple servers by
using ns_socklisten/accept:

http://www.junom.com/gitweb/gitweb.perl?p=3Dtwt.git;a=3Dtree;f=3Dpackages/tclbean/tcl;h=3D8f0100

tom jackson


On Tue, Aug 18, 2009 at 5:56 AM, Nikolay Shulga<nikolay...@runway.lv> w=
rote:


> Hello,
>
> Is it possible to use Aolserver as multithreaded TCL socket server ?
>
> If I connect to Aolserver using telnet , the server waits one of HTTP
> comands from me. But it would be good to have full access to the socket ,

> from TCL script, without being obliged to send HTTP GET or other requests=
.
>
> ns_register_proc - unfortunately doesn't give such a possibility, I can h=


ave
> access to the socket but only after HTTP request has been sent.
>
> ns_socklistencallback - it gives full controll over the channell , but
> process only one client at the moment. It will accept connections from

> several clients, but will process only the first one. The others will blo=
ck


> untill the first one will disconnect.
>
> Please , if anyone knows the solution for this, share it with me .


--

Reply all
Reply to author
Forward
0 new messages