Zonarius Posted August 29, 2008 Share Posted August 29, 2008 Maybe I'm doing something wrong, but please try this: TCPStartup() myGet("www.google.at", "/intl/de_at/images/logo.gif") TCPShutdown() Func myGet($host, $file, $headers = "") Local $req Local $ip Local $ms Local $fp Local $recv $req = "GET " & $file & " HTTP/1.1" & @CRLF $req &= "Host: " & $host & @CRLF $req &= $headers $req &= @CRLF $ip = TCPNameToIP($host) $ms = TCPConnect($ip, 80) TCPSend($ms, $req) Sleep(1000) $recv = TCPRecv($ms, 1000000) TCPCloseSocket($ms) $fp = FileOpen("logo.gif", 2) FileWrite($fp, BinaryToString($recv)) FileClose($fp) EndFunc ;==>myGet What I receive is this: HTTP/1.1 200 OK Content-Type: image/gif Last-Modified: Fri, 07 Dec 2007 01:42:40 GMT Expires: Sun, 17 Jan 2038 19:14:07 GMT Cache-Control: public Date: Fri, 29 Aug 2008 06:29:53 GMT Server: gws Content-Length: 9320 GIF89a9n A bit too little for a picture. So I watched traffic with a tool and I do receive the complete image, but i don't get it with AutoIt. Is this a bug or am I doing something wrong? Link to comment Share on other sites More sharing options...
martin Posted August 29, 2008 Share Posted August 29, 2008 Maybe I'm doing something wrong, but please try this: TCPStartup() myGet("www.google.at", "/intl/de_at/images/logo.gif") TCPShutdown() Func myGet($host, $file, $headers = "") Local $req Local $ip Local $ms Local $fp Local $recv $req = "GET " & $file & " HTTP/1.1" & @CRLF $req &= "Host: " & $host & @CRLF $req &= $headers $req &= @CRLF $ip = TCPNameToIP($host) $ms = TCPConnect($ip, 80) TCPSend($ms, $req) Sleep(1000) $recv = TCPRecv($ms, 1000000) TCPCloseSocket($ms) $fp = FileOpen("logo.gif", 2) FileWrite($fp, BinaryToString($recv)) FileClose($fp) EndFunc ;==>myGet What I receive is this: HTTP/1.1 200 OK Content-Type: image/gif Last-Modified: Fri, 07 Dec 2007 01:42:40 GMT Expires: Sun, 17 Jan 2038 19:14:07 GMT Cache-Control: public Date: Fri, 29 Aug 2008 06:29:53 GMT Server: gws Content-Length: 9320 GIF89a9n A bit too little for a picture. So I watched traffic with a tool and I do receive the complete image, but i don't get it with AutoIt. Is this a bug or am I doing something wrong? I would expect that you should open the file in binary mode and save the recieved data without converting it to a string $recv = TCPRecv($ms, 1000000,1);force binary TCPCloseSocket($ms) $fp = FileOpen("logo.gif", 16+2);force binary FileWrite($fp, $recv); FileClose($fp) but that still doesn't work. This works inetget("http://www.google.at/intl/de_at/images/logo.gif","logo2.gif") but that might not be any help. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Zonarius Posted August 29, 2008 Author Share Posted August 29, 2008 It works with inetget, but it has to work with the TCP functions, doesn't it? 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