kned Posted October 28, 2007 Share Posted October 28, 2007 im using this in my download script: $sDataBuff = TCPRecv( $hSocket, 1024) when i try to get a picture from a http server this way i always get binary data BinaryToString($data) works but just gives me pieces of data my packet capture tool shows me that i got the data but autoit doesnt get it or only gets pieces already searched the forum but didnt find anything any ideas? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 28, 2007 Moderators Share Posted October 28, 2007 im using this in my download script:$sDataBuff = TCPRecv( $hSocket, 1024)when i try to get a picture from a http server this way i always get binary dataBinaryToString($data) works but just gives me pieces of datamy packet capture tool shows me that i got the data but autoit doesnt get it or only gets piecesalready searched the forum but didnt find anythingany ideas?I love that saying.. "I searched the forum but didn't find anything", if you searched, you found plenty, now whether you felt like wading through all of the data is a different story.How big is the string your sending in binary?I'd suggest you show the client/server script you're using. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kned Posted October 28, 2007 Author Share Posted October 28, 2007 im not sending anything $req="GET images.jpg HTTP/1.1"&@CRLF $req&="Host: somehost.info"&@CRLF $req&="Range: bytes=0-"&@CRLF $req&="User-Agent: some client"&@CRLF $req&="Accept: */*"&@CRLF $req&="Referer: "&$link&@CRLF $req&="Accept-Encoding: "&@CRLF&@CRLF gets send to a http server, so i get the picture back in my case its a 700kb picture, but autoit only gets parts of the data after binarytostring($picturedata) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 28, 2007 Moderators Share Posted October 28, 2007 im not sending anything $req="GET images.jpg HTTP/1.1"&@CRLF $req&="Host: somehost.info"&@CRLF $req&="Range: bytes=0-"&@CRLF $req&="User-Agent: some client"&@CRLF $req&="Accept: */*"&@CRLF $req&="Referer: "&$link&@CRLF $req&="Accept-Encoding: "&@CRLF&@CRLF gets send to a http server, so i get the picture back in my case its a 700kb picture, but autoit only gets parts of the data after binarytostring($picturedata)I imagine that autoit is only getting 1024 characters, they way you have it set up. Do you have your TCPRecv in a loop? Did you try increasing the size limitation? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kned Posted October 28, 2007 Author Share Posted October 28, 2007 i am using async sockets posted somwhere in the forum _ASockSelect( $hSockets[ $i ], $hNotifyGUI, $WM_USER + $i, BitOR( $FD_READ, $FD_WRITE, $FD_CONNECT, $FD_CLOSE ) ) GUIRegisterMsg( $WM_USER + $i, "OnSocketEvent" ) ; onevent run func .. _ASockConnect( $hSockets[ $i ], $IP, $PORT ) Func OnSocketEvent( $hWnd, $iMsgID, $WParam, $LParam ) Case $FD_READ; Data has arrived! $sDataBuff = TCPRecv( $hSocket, $N_MAXRECV) _FileWriteAPI($fhandles[$shandle[$id]], binarytostring($sDataBuff), $filepointer[$id]) endfunc these are the main parts of the script on change call onsockevent if event=read then receive and write to file ... the original picture is filled with signs, the data which gets written to the file is like " *empty lines* *about 100 signs* *more empty lines*" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 28, 2007 Moderators Share Posted October 28, 2007 i am using async sockets posted somwhere in the forum _ASockSelect( $hSockets[ $i ], $hNotifyGUI, $WM_USER + $i, BitOR( $FD_READ, $FD_WRITE, $FD_CONNECT, $FD_CLOSE ) ) GUIRegisterMsg( $WM_USER + $i, "OnSocketEvent" ) ; onevent run func .. _ASockConnect( $hSockets[ $i ], $IP, $PORT ) Func OnSocketEvent( $hWnd, $iMsgID, $WParam, $LParam ) Case $FD_READ; Data has arrived! $sDataBuff = TCPRecv( $hSocket, $N_MAXRECV) _FileWriteAPI($fhandles[$shandle[$id]], binarytostring($sDataBuff), $filepointer[$id]) endfunc these are the main parts of the script on change call onsockevent if event=read then receive and write to file ... the original picture is filled with signs, the data which gets written to the file is like " *empty lines* *about 100 signs* *more empty lines*"That information isn't very helpful, and I'm certainly not going to chase something down to help when you've should have posted everything to begin with (including the functions you're referring too, not just their calls). You also may want to use code tags when you post code: **code here**[ /code] (without the space after the bracket) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Siao Posted October 28, 2007 Share Posted October 28, 2007 Not sure what you're trying to achieve with that BinaryToString(). When converting to string, binary gets cut off at first null byte (terminator char in strings). Binary data can have a lot of null bytes. Image is binary data. So if you want to write to file, don't convert to string and use binary write mode. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
kned Posted October 28, 2007 Author Share Posted October 28, 2007 (edited) if you really want to go trough .. here it is try to get the image in your folder ...as.au3 Edited October 28, 2007 by kned Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 28, 2007 Moderators Share Posted October 28, 2007 Not sure what you're trying to achieve with that BinaryToString().When converting to string, binary gets cut off at first null byte (terminator char in strings). Binary data can have a lot of null bytes. Image is binary data. So if you want to write to file, don't convert to string and use binary write mode.Good point, I typically Base64 mine. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kned Posted October 28, 2007 Author Share Posted October 28, 2007 works with filewrite binary .. but sux >< 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