On Apr 19, 2009, at 3:20 AM, Jose Enrique Benitez Jimenez wrote:

Hello friends,

Do any of you can tell me how to get a string of any size by socket?

I use this:
 {MyClient receive(list:Mensaje size:1000000)}

but the string it receives is bigger, so it is cut into pieces, but I need get it all.

http://www.mozart-oz.org/documentation/system/node55.html#chapter.open

method read: The atom all is also a legal value for SizeAI.

You can also call read recursively. Here is some snipped I just copied from some program of mine.

   local
      proc {Aux Socket Size Stream}
         In = {Socket read(list:$
                           size:Size)}
      in
         {Wait In}
         %% abort condition when client stream ended (i.e. nothing was sent)
         if In == nil
         then {System.showInfo "socket stream ended"}
            Stream = nil
         else Stream = In | {Aux Socket Size}
         end
      end
   in
/** %% The socket Server returns a stream of the strings it receives. The Server always waits until someone writes something into the socket, then the input is immediately written to a stream and the Server waits again.
      %% */
      proc {ReadToStream Socket Size Xs}
         thread {Aux Socket Size Xs} end
      end
   end


Best
Torsten

--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
Office: +44-1752-586219
Private: +44-1752-558917
http://strasheela.sourceforge.net
http://www.torsten-anders.de




_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to