Jump to content

HTTPRequest


Recommended Posts

Hi everybody,

I have the following script which keeps hanging in an endless loop :

Dim $body, $sc, $request, $addr, $path

$path = "/"
$addr = "www.xs4all.nl"

TCPStartup()

$sc = TCPConnect(TCPNameToIP($addr), 80)

If NOT $sc < 0 Then
    MsgBox(16, "Connection Problem", @error & " Problem while connecting to host")
    exit(1)
EndIf

$request = "GET " & $path & " HTTP/1.0" & @CRLF & "Host:" & $addr & @CRLF & @CRLF

$data = TCPSend($sc, $request)

While 1
    $line = TCPRecv($sc, 1024)

    If NOT StringLen($line) = 0 Then

        msgbox(64, "data", StringLen($line))
        exit(1) 
    EndIf

WEnd

Does anybody have a clue why $line stays empty ?

The only thing I can think of is that the $request value is invalid.. but if that would be the case, at least an error would be received right ?

Thanks in advance!

Link to comment
Share on other sites

since you don't show the function TCPRecv($sc, 1024), it is a bit hard to determine if you are returing something.

;......
While 1
    $line = TCPRecv($sc, 1024)

    If NOT StringLen($line) = 0 Then; if length of $line=0 then loop endlessly

        msgbox(64, "data", StringLen($line))
        exit(1) 
    EndIf
    tooltip(@min & ":" & @sec,0,0); click the time 

WEnd
If you are in an endless loop, it could be one of the earlier functions, of you don't have a return in the TCPRev()

func TCPRecv($sc, $length)
$sc=$sc+1
return $sc*$length; make sure you are sending back the result.
endfunc

I would also put in a monitor so you can see where it is stuck

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...