For Programmers: Free Programming Magazines  


Home > Archive > Tcl > May 2006 > tcl socket synchr problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author tcl socket synchr problem
beet

2006-05-31, 7:12 pm

I have one question about client file event in the following code:
>
> exec ~/bin/wish8.4 graph01.tcl &
> ### after this I want to have the client id updated with the new one...see proc server_accept
> puts $newcid [list setRecord $recordIndex $arg1 $arg2 newsock]
>
> ### I tried to send the cmd to the newest created client id...which is supposed
> ### to be obtained from the following proc...
>
> proc server_accept {cid addr port} {
> global cidlist nametypecidlist newid
> if {[lsearch $cidlist $cid] == -1} {
> lappend cidlist $cid
> puts $cid "getmycid $cid"
> lappend nametypecidlist ${cid}name plot $cid
> set newid $cid
> }
> fileevent $cid readable "server_handle $cid"
> fconfigure $cid -buffering line
> }
>

I guess I had the synchr problem, until it runs through server_handle,
I wont
be able to get the cidlist updated. Do you have any idea to solve this
problem.
I hope server_accept and server_handler are independent of each other,
but
it seems the server just processes them one by one.

thanks a lot,
Beet

Michael A. Cleverly

2006-05-31, 10:04 pm

On Wed, 31 May 2006, beet wrote:

> I have one question about client file event in the following code:
> I guess I had the synchr problem, until it runs through server_handle,
> I wont
> be able to get the cidlist updated. Do you have any idea to solve this
> problem.
> I hope server_accept and server_handler are independent of each other,
> but
> it seems the server just processes them one by one.


You haven't shown us what server_handler does.
David Gravereaux

2006-05-31, 10:04 pm

On 31 May 2006 09:02:32 -0700, "beet" <whhggg@gmail.com> wrote:

>I guess I had the synchr problem, until it runs through server_handle,
>I wont
>be able to get the cidlist updated. Do you have any idea to solve this
>problem.



Just wait for the readable fileevent to come around and pick-up the
instance from where it left off. It appears you sent the command, so then
wait for the reply.


>I hope server_accept and server_handler are independent of each other,
>but
>it seems the server just processes them one by one.



Event handlers are atomic and run one after the other.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com