This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

socket info

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

socket info

Post by Ofloo »

is a server socket in tcl multi threaded under an eggdrop yes or no..

can there be 2 sessions at once ..?
XplaiN but think of me as stupid
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

according to the TCL doc, it does.
For each connection Tcl will create a new channel that may be used to communicate with the client.
but probably these functions itself cannot run at the same time, they will run one after another. but that should be no problem. when you use non-blocking I/O.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

no i am asking for global variables so they don't overwrite eachother..
XplaiN but think of me as stupid
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

using the -async switch usually yields the best results with sockets
if you find a better way, please let us know :)
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Ofloo wrote:no i am asking for global variables so they don't overwrite eachother..
there are no global default variables using [socket -server <port>], or are you asking something else?
if you are going to save the sock# like $::sock you will of course encounter an overwrite of the variable, but luckly you won't need to save it outside the interacting proc, because the proc will be called with the sock# as argument, maybe you should really read The Manual?!
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

De Kus wrote:according to the TCL doc, it does.
For each connection Tcl will create a new channel that may be used to communicate with the client.
but probably these functions itself cannot run at the same time, they will run one after another. but that should be no problem. when you use non-blocking I/O.
my question is if there will be a new scope for each connection like threads with a parrent its actualy for my webserver in tcl i am asking i can't find the thread on the forum but i once asked how to do code evaluation there did user suggested to use namespaces and a global return variable problem is if sessions do overwrite each other then i can't use global variables like that (not the command global but variable, just saying global variable cause i mean its not local inside the proc)
DragnLord wrote:using the -async switch usually yields the best results with sockets
if you find a better way, please let us know :)
-async is not supported by servers
XplaiN but think of me as stupid
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I misunderstood what your aim was.
Can you post some of the code you want to use?
Might help to understand it a little better.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm its kinda big it works its finished just don't wana come before suprises later on.. more then one file..
XplaiN but think of me as stupid
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

:) I guess the only way to find out is to use it for a while.
Variable arrays based on -socketname (if used) may help.
Hard to give advice with not enough info for me to work with.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

DragnLord wrote::) I guess the only way to find out is to use it for a while.
Variable arrays based on -socketname (if used) may help.
Hard to give advice with not enough info for me to work with.
its not me whom is gone use it so i might find out only months later.. couldn't hurt to ask tho ..
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

TCL doesn't implement threads - but you can emulate threads using multiple interpeters; there is however the Thread extension which allows you to experience the wonderful pitfalls of multithreaded programming

I highly doubt you need threads to drive your purely event-driven I/O tasks
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

demond wrote:TCL doesn't implement threads - but you can emulate threads using multiple interpeters; there is however the Thread extension which allows you to experience the wonderful pitfalls of multithreaded programming

I highly doubt you need threads to drive your purely event-driven I/O tasks
just as i expected but i can't say that answers my question.. does socket -server open a new interpreter each time yes or no ? also i sad "like" threads never sad it used em, if it uses multiple sessions i know it would open tclsh just an other time .. thing is does it yes or no ..

so basicly does server socket open a new interpreter which i highly doubt

it also can open a new interpreter without making a new scope like this it could make one scope and multiple threads..

Code: Select all

socket -server server 6666

proc server {s i p} {
  global somevar
}
for example if the above is the case and 2 connections are made at once will somevar overwrite the data in the other connection ? or will it delay it and finish one at the time ..
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

no and no

it won't create a new interpreter

it won't overwrite other connection's data

quoting from [socket] manpage:
Server sockets depend on the Tcl event mechanism to find out when new connections are opened. If the application doesn't enter the event loop, for example by invoking the vwait command or calling the C procedure Tcl_DoOneEvent, then no connections will be accepted.
I'm unsure what exactly your problem is; maybe you need to clarify

If you just need to get a TCL server app to work, check out TCL's wiki for simple examples
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

never mind i found out server socket waits untill one thread is done then moves on to the next one..
XplaiN but think of me as stupid
Locked