Jump to content

Get data from HTTP server with AU3 network functions


Recommended Posts

As part of a script I'm making I want to get data from a server on a LAN. Its just a line of text.

Initially I created my own server that waited for a connection and sent the data, which worked fine.

However, this server already has IIS running on it and I thought a better solution would be to have the data served by the web server. The file is stored in a PHP file.

However I'm having a problem getting data from the web server via autoit's tcp commands. I'm pretty sure I'm missing a fairly obvious concept. Here is my code so far:

$sendvar = "GET /screensaver/ss.php  HTTP/1.1" & @CRLF & "Host: help" & @CRLF & @CRLF

TCPStartup()

$socket = TCPConnect ( "200.0.0.14", "80" )

TCPSend ( $socket, $sendvar )

$data = TCPRecv ( $socket, 1000)

TCPCloseSocket ( $socket )

TCPShutdown()

msgbox(0,"",$data)

Exit

The server is on the IP address of 200.0.0.14, with the web service running on port 80. I think the problem is that I know how to send the GET request (stored in $sendvar) but I'm not sure how to then receive the data that the web server returns.

Any ideas? At the moment the messagebox debug I put is just empty.

Thanks in advance!

edit: just to point out that I don't want to implement this using inetget() as not all users will have IE installed.

Edited by sjorrel
Link to comment
Share on other sites

The file is stored in a PHP file.

Do you mean you're trying to download a file from IIS, or the PHP script is just giving you some text? Given the MsgBox line, I'm assuming ss.php is giving you text.

If you're just getting HTTP data, why not use InetGet?

$url = "http://200.0.0.14/screensaver/ss.php"
$data = InetGet($url)
msgbox(0,"",$data)
Edited by c0deWorm

My UDFs: ExitCodes

Link to comment
Share on other sites

while $data = ""

$data = TCPRecv ( $socket, 1000)

wend

Thats what I needed. Thanks!

Although I had to do it this way:

while $data = ""
$data = TCPRecv ( $socket, 1000)
wend

$data = ""

while $data = ""
$data = TCPRecv ( $socket, 1000)
wend

To get $data to equal the actual content of the php page as the first time round it was the heads. I was expecting the $data to equal both the headers and page contents.

My solution doesn't seem very elegant, but at least it works!

Edited by sjorrel
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...