mIRC Homepage
I have 3 scripts that use sockets. They work fine in 6.35, but in the beta, they fail between the sockopen event and the sockread event. I can see an echo at the end of the sockopen event, so it's completing, and $sockerr there shows 0, so there's no socket error there. However, I can't get an echo from the very first line of the sockread event, so it's not triggering that event for some reason.
My socket scripts are working fine.
Sockets work fine here. This might be a firewall issue for you, did you check your firewall?

Can you provide an example script?
I've been helping people with firewall issues for many years... it's not a firewall issue. The scripts work just fine in 6.35, so it's a change in 7.0 beta and all my scripts are available from www.kakkoiitranslations.net/mircscripts/ . The weather, dictionary, or bible scripts are all socket scripts. Also, I'm not the only one with issues using the scripts in beta.
I am one of the people who reported this issue to Ram...

It is NOT a firewall issue, if it were, it would not work on 6.35 and NOT on 7.0 when both are running (at the same time) from the same machine. There is some issue in this area, and I think we need to let K. look at this to determine what the issue is... I am on XP and other are on windows 7 so it does not seem to be an os related issue either..

Hope this helps to track it down.

I have not been able to reproduce this so far. I created a test script that downloads pages from a website and it seems to be working correctly. Can you provide a short sample script that reproduces this issue for you?
I'm not able to reproduce this.

Using mIRC v7.0 I whipped up a small script:

Code:
alias vcheck {
  sockclose vcheck
  sockopen vcheck www.mirc.com 80
}

on *:sockopen:vcheck:{
  if ($sockerr) { 
    echo -a ERROR $sock($sockname).wserr : $sock($sockname).wsmsg
    return
  }
  sockwrite -n $sockname GET /get.html HTTP/1.1
  sockwrite -n $sockname host: www.mirc.com
  sockwrite -n $sockname
}

on *:sockread:vcheck:{
  var %data
  sockread %data
  if (*the latest version is* iswm %data) {
    echo -a $replace(%data,<strong>,$chr(2),</strong>,$chr(2))
    sockclose $sockname
  }
}


This runs fine and correctly echoes the mIRC version from the download page.
I'll get something as soon as I get home. Have you tried with HTTP/1.0? Perhaps that's the cause... maybe a change in beta makes 1.0 not work? I can't check into anything right now to see. It's possible there's some issue in the scripts, but without being able to get any error message or echo result to show me what's happening, I'm at a standstill and haven't been able to really spend much time with it.
HTTP/1.0 works fine for me too - it may be something to do with your particular script or the website you're connecting to.
Ok, I found the cause.

I had previously been combining the final $crlf with the last sockwrite line using $+ rather than as a separate line. This worked fine in 6.35, but apparently won't work anymore. With a separate line added for the $crlf (or just a blank -n line), it works fine.

So this isn't a bug and the way I was doing it before was probably just luck that it worked as it probably wasn't intended to work that way. That said, I've seen others use the same methods and if there isn't a reason not to allow it, I think it might be better to maintain that ability rather than forcing any scripts that had used that method to update. Up to you though. I'll change them anyhow just to make them "correct." wink
Riamus2,

when you get this resolve, (ie new version of the dict and other scripts. let me know online, so i can help the user who reported an issue to me.
Thanks for the great followup on this one smile

Jim

That's odd, as far as I know /sockwrite -n has always worked this way: it will only append a CRLF if the line doesn't already end with one. At least that's what the 6.35 help file says.

You can also send the two CRLFs at the end like so:

Code:
  sockwrite -n $sockname GET /get.html HTTP/1.1
  sockwrite $sockname host: www.mirc.com $str($crlf,2)


This works as you would expect.
This is how I had it end before:

sockwrite -n $sockname Accept: */* $crlf $+ $crlf

That fails. Yes, it could have been done as $str, but I just didn't bother. I just tried it with $str($crlf,2) and it fails as well. It only works if I drop those and add a sockwrite -n $sockname on the next line (actually, if I leave them it works as long the empty -n is on the next line). This is using 1.0 if that matters.
Thanks, I have just reviewed the changes relating to the way CRLFs are handled in custom sockets and a few other features, comparing them with v6.35, and have changed the behavior back to how v6.35 was handling them, so your socket scripts should work again in the next version.
Sounds good. The changes didn't have to be changed back if they were important or useful or whatever. It's an easy change to make them work again (and perhaps is better that way anyhow). Thanks.
It was technically a bug. When /sockwrite -n was used, mIRC v7.0 was stripping out all CRLFs from the end of the line and adding only one CRLF, which it should not have been doing.
The help file should probably be updated then, as this section isn't how /sockwrite behaves:

Quote:
The -n switch appends a $crlf to the line being sent if it's not a &binvar and if it doesn't already have a $crlf.
This description is fine, it's what sockwrite -n do.
What is wrong for you ?
Code:
alias vcheck {
  sockclose vcheck
  sockopen vcheck www.mirc.com 80
}

on *:sockopen:vcheck:{
  if ($sockerr) { 
    echo -a ERROR $sock($sockname).wserr : $sock($sockname).wsmsg
    return
  }
  sockwrite -n $sockname GET /get.html HTTP/1.1
  sockwrite -n $sockname host: www.mirc.com $str($crlf,2)
}

on *:sockread:vcheck:{
  var %data
  sockread %data
  if (*the latest version is* iswm %data) {
    echo -a $replace(%data,<strong>,$chr(2),</strong>,$chr(2))
    sockclose $sockname
  }
}


In mIRC 6.35 (and presumably the next beta), the above code works. However, that contradicts the description of /sockwrite -n. In the above script, in 6.35, the /sockwrite command is adding a CRLF to the end of the line even though there's already two CRLFs at the end.

/sockwrite -n in the help file says:

Quote:
The -n switch appends a $crlf to the line being sent if it is not a &binvar and if it does not already have a $crlf.


In other words, if it does have a CRLF then mIRC shouldn't be adding one.
Are you sure it's adding a third $crlf? Maybe it's seeing 2 and so isn't doing anything as the help file seems to indicate? That would make sense since it still needs 2 $crlf's at the end, but you should only need 1 if -n is adding a $crlf.
You're right.. my mistake. Changing it to one $crlf causes the script to fail. :p
© mIRC Discussion Forums