mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2004
Posts: 10
P
Pingh Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 10
I've been successful in connecting and grabbing data from an open socket that's connected to an http server.

The issue I am having is that it never reads the final line, and in my case that's rather critical.
Has anybody had this issue, or now how I can catch it?
Thanks in advanced.
-pingh

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
This is probably a result of the final line not being terminated with cr/lf and you're trying to read the content into a text variable. mIRC will only read non-cr/lf terminated data into a binary variable.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
From the mIRC helpfile:
/sockread [-fn] [numbytes] <%var|&binvar>

If you specify the -f switch with a %var variable, this forces mIRC to fill the %var variable with whatever text is in the receive buffer, even if it doesn't end in a $crlf.

That might work.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Damn, you replied before I had a chance to edit my post.

Well anyway, yeah that's another way around it.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Just a sidenote.. Due to the way TCP works, using the -f flag with /sockread for a line-based protocol can result in lines being cut in half. As far as I know, the best way of reading the last, non-CR/LF terminated line, without risking that other lines be cut in half, is:

1) to use /sockread without -f in the normal on SOCKREAD event, and,
2) to issue one final /sockread with -f in the on SOCKCLOSE event.

This, of course, only works if the HTTP server closes the connection after sending the reply.


Saturn, QuakeNet staff
Joined: May 2004
Posts: 10
P
Pingh Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 10
Thank you kindly.

I had catched the final line on the sockclose event and it worked flawlessly.

Thank you for your time.


Link Copied to Clipboard