mIRC Homepage
Posted By: phrozenfire Socket Ping - 07/12/03 12:16 AM
Alright, I have this script, but the socket still ping timeouts. Help please. Thanks.

Code:
on 1:sockread:dnn:{
  var %temp | sockread %temp
  if (%temp == PING) { sockwrite -n $sockname PONG $2- }
}
Posted By: phrozenfire Re: Socket Ping - 07/12/03 03:19 AM
Figured it out. I needed:

Code:
on 1:sockread:dnn:{
  var %temp | sockread %temp
  if ($gettok(%temp,1,32) == PING) { sockwrite -n $sockname PONG $2- }
}
Posted By: bleach Re: Socket Ping - 07/12/03 08:31 AM
You can also use "tokenize" command. That allows you to tokenize texts.
Usage; /tokenize <ascii code> <text>
Code:
on 1:sockread:dnn:{  
var %temp 
sockread %temp  
tokenize 32 %temp
if ([color:red]$1[/color] == PING) { sockwrite -n $sockname PONG  [color:red]$2-[/color] }
}

smirk
Posted By: Hitchhiker Re: Socket Ping - 07/12/03 08:31 AM
Glad you figured it out, but just remember there is no tokenized data in sockread unless you use /tokenize, your $2- is null there.
Posted By: bleach Re: Socket Ping - 07/12/03 02:50 PM
Oh I didn't see.
phrozen, you cannot use data as token like $2- by not using tokenize command if theres not already tokenized.
;--------
;there should be like below code if there not using tokenizing;
if ($gettok(%temp,1,32) == ping) sockwrite -tn $sockname pong $gettok(%temp,2-,32)
;--------
by using tokenize command;
if ($1== ping) sockwrite -tn $sockname pong $2-
;-------

© mIRC Discussion Forums