Re: [Gambas-user] using sockets to send binay files
Hi, May be this email can help you. --- On Mon, 1 Dec 2008 06:50:06 am Robert Moss wrote: Robert this may not be much help to you and I'm not sure how related to your problem it is, but just on the off chance. I struggled with saving a picture and retrieving from a postgres field. The code I included worked really well for a long time, but in the last couple of upgrades though it saves the file ok, it retreives a corrupt image. and I get a libpng error (sob sob) and I havn't had time or inclination to re-look at it. Please if/when you figure it out can I have a few pointers. Regards Richard The ImgData stops writing when it comes to a byte with value H00 (I believe) although I'm pretty sure it doesn't matter how I write the stream, once it's read as a String, it becomes terminated by any NULL char. So my question is this: How do I read the data from the Socket in binary, write it to a stream file in binary, but STILL I MUST be able to split the data based on the 2 CRLF's On Sun, Nov 30, 2008 at 11:48 AM, Robert Moss the.at.rob...@gmail.comwrote: Sorry that's not it, I mis-copied the line, in the actual code it does Mid(sData, p1 + 4) On Sun, Nov 30, 2008 at 2:39 AM, Doriano Blengino doriano.bleng...@fastwebnet.it wrote: Robert Moss ha scritto: I am trying to get an image (or any binary data) downloaded from a website and into a jpg file. I expect I will need to use the Byte[] datatype, but I absolutely can NOT use Callbacks when the data comes in this time. ... DO UNTIL(EOF(#Sock)) READ #Sock, sBuf, Lof(Sock) sTotal = sBuf LOOP CLOSE #Sock p1 = InStr(sTotal, \r\n\r\n) ImgData = Mid(sTotal, p1) OPEN localimg.jpg FOR OUTPUT CREATE AS #myFile WRITE #myFile, ImgData, Len(ImgData) CLOSE #myFile I think there is a problem with InStr(...,\r\n\r\n). By taking mid$(...,p1), you retain the two CRLFs, which are not good at the beginning of a jpeg file. You should get rid of the first 4 characters. May be there are still other problems, but this is one for sure. Regards, -- Doriano Blengino Listen twice before you speak. This is why we have two ears, but only one mouth. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user Le 10 avr. 2010 à 23:15, Ricardo Díaz Martín a écrit : Hi, Is there some way to send binary files using gambas sockets? Reading and sending byte per byte is too much slow. I read old post from Benoit about this and I think it's no possible at this time. It's true? Regards, Ricardo Díaz -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user Olivier Cruilles Mail: linu...@club-internet.fr -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance.
Re: [Gambas-user] using sockets to send binay files
Thanks Olivier for your reply. I discovered last night binary files can be sent as text files if you uuencode on before sending and uudecode after files are received. uuencode and uudecode are unix standards commands (they are in Ubuntu repositories and in Mac OX too) The code you put in your mails only works with text files. Regards, Ricardo Díaz 2010/4/11 Olivier Cruilles linu...@club-internet.fr Hi, May be this email can help you. --- On Mon, 1 Dec 2008 06:50:06 am Robert Moss wrote: Robert this may not be much help to you and I'm not sure how related to your problem it is, but just on the off chance. I struggled with saving a picture and retrieving from a postgres field. The code I included worked really well for a long time, but in the last couple of upgrades though it saves the file ok, it retreives a corrupt image. and I get a libpng error (sob sob) and I havn't had time or inclination to re-look at it. Please if/when you figure it out can I have a few pointers. Regards Richard The ImgData stops writing when it comes to a byte with value H00 (I believe) although I'm pretty sure it doesn't matter how I write the stream, once it's read as a String, it becomes terminated by any NULL char. So my question is this: How do I read the data from the Socket in binary, write it to a stream file in binary, but STILL I MUST be able to split the data based on the 2 CRLF's On Sun, Nov 30, 2008 at 11:48 AM, Robert Moss the.at.rob...@gmail.comwrote: Sorry that's not it, I mis-copied the line, in the actual code it does Mid(sData, p1 + 4) On Sun, Nov 30, 2008 at 2:39 AM, Doriano Blengino doriano.bleng...@fastwebnet.it wrote: Robert Moss ha scritto: I am trying to get an image (or any binary data) downloaded from a website and into a jpg file. I expect I will need to use the Byte[] datatype, but I absolutely can NOT use Callbacks when the data comes in this time. ... DO UNTIL(EOF(#Sock)) READ #Sock, sBuf, Lof(Sock) sTotal = sBuf LOOP CLOSE #Sock p1 = InStr(sTotal, \r\n\r\n) ImgData = Mid(sTotal, p1) OPEN localimg.jpg FOR OUTPUT CREATE AS #myFile WRITE #myFile, ImgData, Len(ImgData) CLOSE #myFile I think there is a problem with InStr(...,\r\n\r\n). By taking mid$(...,p1), you retain the two CRLFs, which are not good at the beginning of a jpeg file. You should get rid of the first 4 characters. May be there are still other problems, but this is one for sure. Regards, -- Doriano Blengino Listen twice before you speak. This is why we have two ears, but only one mouth. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user Le 10 avr. 2010 à 23:15, Ricardo Díaz Martín a écrit : Hi, Is there some way to send binary files using gambas sockets? Reading and sending byte per byte is too much slow. I read old post from Benoit about this and I think it's no possible at this time. It's true? Regards, Ricardo Díaz -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during
Re: [Gambas-user] using sockets to send binay files
Hi, Is there some way to send binary files using gambas sockets? Reading and sending byte per byte is too much slow. I read old post from Benoit about this and I think it's no possible at this time. It's true? Regards, Ricardo Díaz Use the WRITE or the PRINT instruction. For example: PRINT #MySocket, File.Load(/path/to/myfile); Don't forget the ; at the end of the PRINT instruction, otherwise a newline will be added. Regards, -- Benoît Minisini -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user