Hello Daniel, It is indeed not a rare situation. Sending the length of the data first is a good idea, I do it often. another simple option is to escape some characters and still use lineMode. You have to escape the LineEnd characters as whell as the escape byte. See also http://wiki.overbyte.be for an article I wrote about sending binary data and several approach for it.
--- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Wednesday, May 7, 2008, 13:46, Daniel Mauric wrote: > Hi, > I'm using plain TCP with TWSocket and would like to send binary > data. So far i've been sending text and used line mode, so I wonder > how to handle binary data. > One option would be to encode to say base64 and so still use line > mode, but that would make data larger, so I'd prefer to send binary > data directly. When sending I do know the size of data I'm about to > send, so I guess I could use first few bytes to specify the length. > The receiver would then use that to figure out how much to read till > the end of the message. > This surely isn't a rare situation, so I assume there are usual ways to do it. > I would appreciate any suggestions or comments. > Regards, > Daniel Mauric -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
