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

Old posts that have not been replied to for several years.
Locked
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

socket

Post by caesar »

Code: Select all

bind dcc n| sock dcc:sock

proc dcc:sock {hand idx text} {
  if {[llength $text] < 2} {
    putdcc $idx "Usage: sock <ip> <port>"
    return
  }
  set host [lindex $text 0]
  set port [lindex $text 1]
  catch {socket $host $port} bla
  if {[string match "sock*" $bla]} {
    putdcc $idx "connection established."
    return
  }
  putdcc $idx "$bla"
}
when I run an *test* he pings timed out. My local (lan) tests where ok, the internet ones he dies (ping timedout or something). Also I have tryed using the connect but I haven't understood exactly how to *control* it. I haven't got an successful thing with it, duno why. An example or something will be nice.
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

This sounds weird...if you don't get a reply from the host you're connecting to the connection should time out within less than a minute (the minimum time it would take your bot to ping timeout)

Try using -async when creating the socket, fconfigure it -blocking 0 and set up a fileevent $bla writable ... dealing with checking the connection. This way there should be no ping timeout no matter how [censored] up your system is :P

here's an alternative method of using catch to figure out if there's an error or not when opening the socket:
if {[catch {socket ...} bla]} {failed...$bla is the error msg} {connected...$bla is the socket id}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Guess I have to test it on other (faster) pc.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Aditionaly, try using eggdrops dns functions to resolve the IP before making a connection.

It may possibly be that Tcl is failing to resolve.
Locked