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.
Old posts that have not been replied to for several years.
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Sun Feb 06, 2005 8:36 am
Code: Select all
#!/usr/bin/tclsh
proc open_sock {host port} {
global done
if {[catch {socket -async $host $port} sock]} {
puts "Connection to $host:$port failed: $sock"
} else {
fileevent $sock writable [list check_sock $sock $host $port]
vwait done($sock)
}
}
proc check_sock {sock host port} {
global done
if {[fconfigure $sock -error]==""} {
puts "Connected to $host:$port"
} else {
puts "Connection to $host:$port failed: [fconfigure $sock -error]"
}
close $sock
set done($sock) 1
}
i am using an async socket in a while to connect to multiple targets at once but there appears to be no difference when i use a async socket or a regular one.. it waits untill the proc has ended .. why is this ?
i am using foreach ... to go true the process any suggestions to speed it up?
XplaiN but think of me as stupid
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sun Feb 06, 2005 2:33 pm
Probably cos of the 'vwait done($sock)'
Once the game is over, the king and the pawn go back in the same box.
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Tue Feb 08, 2005 4:30 pm
well its required in a shell script otherwize the app would close ..
XplaiN but think of me as stupid
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Wed Feb 09, 2005 11:43 am
Eggdrop won't exit when your script ends, so you don't need the vwait.
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Wed Feb 09, 2005 11:56 am
Move the vwait to after your while loop? (remove it from the proc)
stdragon wrote: Eggdrop won't exit when your script ends, so you don't need the vwait.
I don't think he's running it in eggdrop's interpreter:
Have you ever read "The Manual"?
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Thu Feb 10, 2005 1:04 am
where exactly cause ive tryed it and i got would wait forever and script breaks
XplaiN but think of me as stupid
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Thu Feb 10, 2005 1:25 am
and yes sorry hehe by shell i meanth shell script as in tclsh not as in eggdrop shell..
XplaiN but think of me as stupid
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Thu Feb 10, 2005 11:57 am
Ofloo wrote: where exactly cause ive tryed it and i got would wait forever and script breaks
Try this:
Code: Select all
proc open_sock {host port} {
if {[catch {socket -async $host $port} sock]} {
puts "Connection to $host:$port failed: $sock"
return 0
} else {
fileevent $sock writable [list check_sock $sock $host $port]
return 1
}
}
proc check_sock {sock host port} {
global pending
if {[fconfigure $sock -error]==""} {
puts "Connected to $host:$port"
} else {
puts "Connection to $host:$port failed: [fconfigure $sock -error]"
}
close $sock
incr pending -1;
}
proc doit args {
global pending
set pending 0
foreach {host port} $args {
incr pending [open_sock $host $port]
}
while {$pending} {vwait pending}
puts done.
}
doit localhost 22 localhost 23 localhost 25 localhost 110
Have you ever read "The Manual"?