mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
My socket scripts are working fine.

Joined: Mar 2010
Posts: 57
W
Babel fish
Offline
Babel fish
W
Joined: Mar 2010
Posts: 57
Sockets work fine here. This might be a firewall issue for you, did you check your firewall?

Can you provide an example script?

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2004
Posts: 526
Fjord artisan
Offline
Fjord artisan
Joined: Mar 2004
Posts: 526
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.



Help others! It makes the world a better place, Makes you feel good, and makes you Healthy!
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2004
Posts: 526
Fjord artisan
Offline
Fjord artisan
Joined: Mar 2004
Posts: 526
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



Help others! It makes the world a better place, Makes you feel good, and makes you Healthy!
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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.

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
This description is fine, it's what sockwrite -n do.
What is wrong for you ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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.

Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Page 1 of 2 1 2

Link Copied to Clipboard