mIRC Home    About    Download    Register    News    Help

Print Thread
Truncated sockreads #208401 20/01/09 04:41 AM
Joined: Feb 2003
Posts: 106
L
lerpicus Offline OP
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
I am getting some sockreads truncated in a script.
The following line of HTML code is from a web site
Quote:
<A NAME='1991401'></A> Definition</span></TD><TD ALIGN='right' VALIGN='baseline' WIDTH='5%'><SPAN class='fieldValue' style='font-size: 80%; font-weight: bold;'>1.</SPAN></TD><TD ALIGN='left' VALIGN='baseline' WIDTH='70%'><span class="fieldValue" STYLE="font-weight: normal;">a building in which people, esp. members of a family, reside.</span></TD></TR>
. And here is what my script returns from the same page -
Quote:
<A NAME='1991401'></A> Definition</span></T
It's a lot shorter. Now, for some activities size isn't important but I think it does matter in this case. Furthermore, it doesn't always happen. Sometimes the full HTML line is successfully retrieved.
My question, then, is a general one. Is there a method to detect a 'broken' sockread? I have modified the code from the /sockread example in the help file eg
Code:
on 1:sockread:testing:{
 if ($sockerr > 0) return
 :nextread
 sockread %temp
 if ($sockbr == 0) return
 if (%temp == $null) %temp = -
 echo 4 %temp
### my code goes here ###
 goto nextread
}


Thanks for listening!


-
Just because it never happened doesn't mean it isn't true.
Re: Truncated sockreads [Re: lerpicus] #208404 20/01/09 05:12 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Are you using HTTP/1.1 in your calling script? If so, use HTTP/1.0

-genius_at_work

Re: Truncated sockreads [Re: genius_at_work] #208406 20/01/09 06:33 AM
Joined: Feb 2003
Posts: 106
L
lerpicus Offline OP
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
Yep. HTTP/1.1
You may add another chevron to your Genius uniform!

What is it about the difference between HTTP/1.1 and HTTP/1.0 that makes 1.0 'better'?


-
Just because it never happened doesn't mean it isn't true.
Re: Truncated sockreads [Re: lerpicus] #208407 20/01/09 06:50 AM
Joined: Feb 2003
Posts: 106
L
lerpicus Offline OP
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
Hold off on that Chevron!! It is no better with HTTP/1.0 frown

Not withstanding that, an answer to 1.1 vs 1.0 would be welcome


-
Just because it never happened doesn't mean it isn't true.
Re: Truncated sockreads [Re: lerpicus] #208416 20/01/09 02:46 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
HTTP1.1 sends the data as "chunks" that are then suppose to be reassembled by the web browser (or something like that). HTTP1.0 sends the data divided by the 0x0A and/or 0x0D (cr/lf) characters. (From memory, don't quote me on that..)

I never use the $sockbr loop method in my socket scripts, so I don't know if that is affecting your output or not. I always do something like this:

Code:

on *:SOCKREAD:mysock:{
if ($sockerr) return
var %s
sockread %s
echo -a > %s
}



mIRC automatically triggers the sockread event again if more data is in the buffer. If you need to handle all of the data on that line at once, you can write it to a tmp file and read it back later. However, relying on the fact that the lines of a website are returned with the same newline feeds may cause you problems in your script.

-genius_at_work