On Sun, 2004-02-22 at 01:17, Michal Moskal wrote:
> On Sat, Feb 21, 2004 at 04:31:00PM -0800, George Farris wrote:
> > I have some socket code that looks something like this:
> > 
> > byte[] bytes = new byte[1448];
> > do {
> >     len = sock.Read(bytes, 0, (int)1448);
> >     s = Encoding.ASCII.GetString(bytes);
> >     buf.Append(s.Substring(0,len));
> 

Interesting, this code will work as long as the check at the bottom is
1448, any other number and it croaks???  The buffer can be any size
presumably larger than 1448 and it will work.

do {
        byte[] bytes = new byte[500000];
        len = stream.Read(bytes, 0, (int)500000);
        if (len > 0 ) {
                s = Encoding.ASCII.GetString(bytes,0,len);
                buf.Append(s);
        }
        if (len < 1448)
                break;
} while (len > 0);
return buf.ToString(); 

-- 
George Farris <[EMAIL PROTECTED]>

_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to