Kinda long title, but anyways...
I\'ve been looking at these examples, specifically on the parts on writing and reading the size of the message to the byte streams
When you say, "This doesn't work very well at all", I'd be curious about specifically what doesn't work. Are they .NET applications on both ends of the socket? If so, ignore this answer. If not, then could the problem be the byte ordering of the integer? A little endian vs big endian issue? This thread here discusses it:
http://bytes.com/forum/thread225649.html
http://books.google.com/books?id=2zT5b2BS1OUC&pg=PA64&lpg=PA64&dq=c%23+sockets+integers+byte+ordering&source=web&ots=_ISzZZ6HHT&sig=tUHdNT0NGv0uxusmHG9YjFw6j9k&hl=en&sa=X&oi=book_result&resnum=2&ct=result
Another problem if both ends aren't .NET could be that the other end expects ANSI strings whereas you are sending Unicode.