sjorrel Posted January 5, 2006 Share Posted January 5, 2006 (edited) 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 January 5, 2006 by sjorrel Link to comment Share on other sites More sharing options...
w0uter Posted January 5, 2006 Share Posted January 5, 2006 look at some of the examples around the forum about binary file sending. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
pingpong24 Posted January 5, 2006 Share Posted January 5, 2006 while $data = "" $data = TCPRecv ( $socket, 1000) wend NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
Gigglestick Posted January 5, 2006 Share Posted January 5, 2006 (edited) 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 January 5, 2006 by c0deWorm My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
w0uter Posted January 5, 2006 Share Posted January 5, 2006 I don't want to implement this using inetget() as not all users will have IE installed. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
sjorrel Posted January 6, 2006 Author Share Posted January 6, 2006 (edited) 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 January 6, 2006 by sjorrel Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now