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.

Sockets question

Old posts that have not been replied to for several years.
Locked
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

Sockets question

Post by Jag »

Hi,
I have a little question about this script:

Code: Select all

proc socks_monitor {nick ip} {
  global hst prt sport
  set hst "$ip"
  set prt "1080"
  catch {socket $hst $prt} sport
  if {([string range $sport 0 3] == "sock") && ([lindex $sport 1] == "")} {
    close $sport
    putserv "privmsg Jag Yes"
    return 0
  }
  putserv "privmsg Jag No"
  close $sport
  return 0
}
This script is working very well when it's a proxy/socks.
but, if it's not a proxy/socks, the eggdrop get into a big lag for a few minutes, and don't send me the message "No".
Somebody knows why? :\
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I'm not sure, but try to use "else" and close $sport before sending no.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Sockets question

Post by user »

Jag wrote:This script is working very well when it's a proxy/socks.
but, if it's not a proxy/socks, the eggdrop get into a big lag for a few minutes, and don't send me the message "No".
Somebody knows why? :\
This is because tcl is waiting for the tcp layer in your os to let the connection time out. The reason it takes so long is probably because the host you're trying to connect to is dropping your syn packet, so you don't get an explicit "connection refused" even though the port is not open. (or the host might be dead)

Try using -async when creating the socket. Then 'socket' will return immediately and you'll be able to set up a callback using 'fileevent' (writable) to have a second proc called when the connection succeeds/fails. This won't speed up the timeout, but allow your bot to do other things while waiting.
Have you ever read "The Manual"?
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

Post by Jag »

10x :P
Locked