mIRC Homepage
Posted By: Erra Sockets and Windows Vista - 10/12/08 04:34 AM
Hi there, Sorry if this has been asked before, but I have searched around for this for a number of days now. I have been unable to find a solution. (Although I found other scripts where people say they have fixed this issue)

I am running a TVrage lookup script. I wrote this one myself, but based loosely on some other code I found. It works perfectly in windows XP but when I put it into Vista UltimateX64, I get the following in the status window.

Code:
/sockwrite: 'checktv' not connected (line 129, tvrage.mrc)


Line 129 is as follows.

Code:
 sockwrite checktv GET www.tvrage.com/quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf


I have tried with and with out the http://.

I have disabled my firewall.

I have reinstalled mirc and moved all scripts into the Vista folder structure.

I have put some echo's in further up, and everything about the script works fine, just until it attempts to connect to the internet and access tvrage.com.

Can anyone help me? Is there a solution to this problem? Or is the solution to get rid of Vista and go back to XP. (I only went to Vista for DirectX10 support anyway really) smile

All help appreciated. This is above my knowledge

Thanks

Oh and Im running Mirc 6.5. latest version just to make sure.
Posted By: Joe_Dean Re: Sockets and Windows Vista - 10/12/08 05:58 AM
I don't know anything about sockets, but taking a quick look at the help file, I'd say you'd need to open the connection before you do anything else.

/help /sockopen

I apologize if I'm wrong, but it's just a suggestion. :P
Posted By: DJ_Sol Re: Sockets and Windows Vista - 10/12/08 06:02 AM
Don't use the domain name with GET, use the path.

sockwrite checktv GET quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf

I also add the http auth stuff in this line.
Code:
sockwrite checktv GET quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf $+(HTTP/1.0,$crlf,User-Agent: WaTech,$crlf,Accept:) $+(*/*,$crlf,Host:) www.domain_name



None of my socket scripts have had any issues transitioning from XP to Vista.

If this doesn't fix it then I would verify the status of your connection during the different sock events.
Posted By: Erra Re: Sockets and Windows Vista - 10/12/08 08:52 AM
Joe_Dean Thanks for the suggestion. I do have a sockopen line a bit further up.
Code:
 sockopen checktv http://www.tvrage.com 80
}

on *:sockopen:checktv: {
  sockwrite checktv GET quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf $+(HTTP/1.0,$crlf,User-Agent: WaTech,$crlf,Accept:) $+(*/*,$crlf,Host:) www.tvrage.com
}


DJ_Sol, I tried what you suggested, as above, but it still isnt working.

It seems that it is not able to connect to the internet on port 80. No idea why this is seeing as it worked on XP, and my firewall is off, and, I havent changed anything on the router. (And I can access the webpage on port 80 through a browser..)
Posted By: DJ_Sol Re: Sockets and Windows Vista - 10/12/08 01:14 PM
Dont use http:// on sockopen.

Code:
/sockopen checktv www.tvrage.com 80
Posted By: Erra Re: Sockets and Windows Vista - 11/12/08 05:48 AM
Thanks for that DJ_Sol.

I no longer get the error at all. The script still isnt doing what it should, and it is not returning any data. But that is obviously something else, so now I just need to work on why that is.

Thanks again!!

Posted By: MTec007 Re: Sockets and Windows Vista - 11/12/08 04:11 PM
I beleive your problem was the line:
sockwrite checktv GET quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf $+(HTTP/1.0,$crlf,User-Agent: WaTech,$crlf,Accept:) $+(*/*,$crlf,Host:) www.tvrage.com

which sould be
sockwrite checktv GET /quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf $+(HTTP/1.0,$crlf,User-Agent: WaTech,$crlf,Accept:) $+(*/*,$crlf,Host:) www.tvrage.com

my test case was as follows:
Code:
alias tst.open { sockopen checktv www.tvrage.com 80 }
on 1:SOCKOPEN:checktv: {
  if ($sockerr > 0) return
  sockwrite -n $sockname GET /quickinfo.php?show=My_Name_Is_Earl&exact=1 HTTP/1.0
  sockwrite -n $sockname Host: tvrage.com
  sockwrite -n $sockname Connection: keep-alive
  sockwrite $sockname $crlf
}
on 1:SOCKREAD:checktv: {
  sockread -f &data
  bwrite tst.txt -1 -1 &data
}


tst.txt returns:
Code:
Date: Thu, 11 Dec 2008 16:08:03 GMT
Server: Apache/2.2.10 (Unix) PHP/5.2.5
X-Powered-By: PHP/5.2.5
Content-Length: 348
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

Show Name@My Name Is Earl
Show URL@http://www.tvrage.com/My_Name_Is_Earl
Premiered@2005
Latest Episode@04x12^Reading Is a Fundamental Case^Dec/04/2008
Next Episode@04x13^Orphan Earl^Dec/11/2008
RFC3339@2008-12-11T:00-5:00
Country@USA
Status@Returning Series
Classification@Scripted
Genres@Comedy
Network@NBC
Airtime@Thursday at 08:00 pm
Runtime@30
Posted By: Erra Re: Sockets and Windows Vista - 11/12/08 06:16 PM
tested your test one there, and I get the tst.txt file, but there is nothing in it.

This is the same issue I have currently with the other script. All appears ok, but nothing writes to the text file as it should...

When I replace &data with just some text, that is written in. So it must still be a connection to the website issue... not too sure.

Thanks for that though.

Posted By: MTec007 Re: Sockets and Windows Vista - 11/12/08 10:04 PM
see below.
Posted By: MTec007 Re: Sockets and Windows Vista - 11/12/08 10:05 PM
Have you checked to make sure mIRC can connect to port 80? Try this script if you will. It may take up to a couple minutes for the error message to be returned. so be patient.
Quote:

alias tst.open { sockopen checktv e-motz.com 80 }
on 1:SOCKOPEN:checktv: {
if ($sockerr > 0) echo -a $sock($sockname).wsmsg | return
sockwrite -n $sockname GET / HTTP/1.0
sockwrite -n $sockname Host: e-motz.com
sockwrite -n $sockname Connection: keep-alive
sockwrite $sockname $crlf
}
on 1:SOCKREAD:checktv: {
sockread -f &data
bwrite tst.txt -1 -1 &data
}
Posted By: argv0 Re: Sockets and Windows Vista - 11/12/08 10:25 PM
Originally Posted By: Erra
Oh and Im running Mirc 6.5. latest version just to make sure.


I assume you mean 6.35

Vista has no known reported issues with mIRC sockets since the first officially supported version (and even before that), and afaik winsock has not changed all that much since XP, so I doubt it has anything to do with vista itself. It *could* be the x64 part, but I doubt that too.

Are you sure there isn't some other problem with the script that occurred in copying it over to your new install? Perhaps you aren't opening the socket or something?

Given that you were still making changes to your script in this forum post I find it hard to believe that the script worked in XP, especially since your original script file was incorrect to begin with (the GET request is invalid as mentioned by others). Can you confirm the fact that the original script file "works" in XP? By "original", I mean the script that included the (invalid) line you pasted:

Code:
sockwrite checktv GET www.tvrage.com/quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf


I assume your claim about the script working in XP included the above line of code, yes?
Posted By: Erra Re: Sockets and Windows Vista - 11/12/08 10:36 PM
Yes it did work miraculously from what I read it shouldnt have, but, it did.

The interesting this here is that the test script above doesnt work either. I dont get an error anymore, but I also dont get any results.

I have fired up Wireshark to see if that will show me what is happening. I get the following

Code:
GET www.tvrage.com/quickinfo.php?show=&exact=1

GET /quickinfo.php?show=My_Name_Is_Earl&exact=1 HTTP/1.0

Host: tvrage.com

Connection: keep-alive



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.

</p>
<hr>
<address>Apache/2.2.10 (Unix) PHP/5.2.5 Server at newinst.layeredtech.com Port 80</address>
</body></html>


So it is connecting out, it just doesnt like it for some reason. But, it is connecting out, which is more than it was when I posted this thread!! smile (Which is great!)

MTec007, I tried that script of yours, didnt get any errors and I waited quite a while. (10 mins)

Thanks

Posted By: argv0 Re: Sockets and Windows Vista - 11/12/08 10:52 PM
Your last example sends *TWO* GET headers, one malformed one and one normal one. It should only be sending the latter, and it should only have ONE crlf after every line but the last (if you use sockwrite -n, do not append a $crlf)

Computers don't do miracles. If you were actually sending the GET request you described above, it was *not* working in XP

In fact, what you just posted is what you should have been getting in XP with that same request. Go to your XP machine and confirm this.
Posted By: Erra Re: Sockets and Windows Vista - 11/12/08 11:13 PM
The result I posted above from wireshark was from MTec007's first test script about 6 lines up.

The original script was definately working as I have been running it fine for about 6-8 months on XP.

here is the original, working 100% in XP script snippet. Even more of it this time smile

Code:
; Get TV Data
alias GetTVData {
  sockopen checktv www.tvrage.com 80
}

on *:sockopen:checktv: {
    sockwrite checktv GET www.tvrage.com/quickinfo.php?show= $+ %checktv $+ &exact=1 $+ $crlf
}

on *:sockread:checktv: {
  ;if (. !isin $read(release.txt, 9)) { halt }
  if ($sockerr) { return }
  var %data
  sockread %data
  set %show.name $gettok(%data,2,64)
  while ((!$sockerr) && ($sockbr)) {
    %checktv.data = %checktv.data $+ %data
    sockread %data
    if (url isin %data) { set %show.url $gettok(%data,2,64) }
    if (country isin %data) { set %show.country $gettok(%data,2,64) }
    if (classification isin %data) { set %show.type $gettok(%data,2,64) }
    if (genres isin %data) { set %show.genres $replace($remove($gettok(%data,2,64),$chr(32)),$chr(124),.) }
    if (premiered isin %data) { set %show.prem $gettok(%data,2,64) }
    if (status isin %data) { set %show.status $gettok(%data,2,64) }
  }
}
on *:sockclose:checktv:{

  if ( %show.type != "" && %show.type != $null ) {
    writeini -n %extradatafile TV %prerls $+( %show.type, $chr(124), %show.country, $chr(124), %show.genres, $chr(124), %show.prem, $chr(124), %show.status )
  }
  unset %checktv*
  unset %show*
}


I will try your other suggestions as well. Thanks for all the help.
Posted By: Erra Re: Sockets and Windows Vista - 11/12/08 11:20 PM
OK worked it out...

For some reason the checktv in sockopen checktv www.tvrage.com 80
was not clearing. I changed checktv to checktv1 in the test script above, and it now returned

Code:
HTTP/1.1 200 OK
Date: Thu, 11 Dec 2008 23:18:46 GMT
Server: Apache/2.2.10 (Unix) PHP/5.2.5
X-Powered-By: PHP/5.2.5
Content-Length: 348
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

Show Name@My Name Is Earl
Show URL@http://www.tvrage.com/My_Name_Is_Earl
Premiered@2005
Latest Episode@04x12^Reading Is a Fundamental Case^Dec/04/2008
Next Episode@04x13^Orphan Earl^Dec/11/2008
RFC3339@2008-12-11T:00-5:00
Country@USA
Status@Returning Series
Classification@Scripted
Genres@Comedy
Network@NBC
Airtime@Thursday at 08:00 pm
Runtime@30


No idea why that was happening, but Im pretty happy now!!!
Posted By: argv0 Re: Sockets and Windows Vista - 11/12/08 11:23 PM
I can confirm that this does not work in WinXP:

Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.10 (Unix) PHP/5.2.5 Server at newinst.layeredtech.com Port 80</address>
</body></html>


Is the response I get from the server when running your script in XP.
Posted By: Erra Re: Sockets and Windows Vista - 12/12/08 03:55 AM
OK so I dont know why it has worked for me then for the past 6-8 months, but it has. Not going to argue the fact, cause I dont know the answer.

Which is why I came here for help

Script is working now with the help from the people here. Really appreciate it. Awesome stuff

Cheers
Erra
© mIRC Discussion Forums