async_read_until and \0

Hello, I'm creating a server using boost:asio and am receiving data that ends with a \0 char (from flash sockets if you're curious) async_read_until seems to not like this as the delimiter. (If I switch to a diff delim like \r\n it works fine) How can I get async_read_until to work properly? thanks, billy

Billy Chasen wrote:
I'm creating a server using boost:asio and am receiving data that ends with a \0 char (from flash sockets if you're curious)
async_read_until seems to not like this as the delimiter. (If I switch to a diff delim like \r\n it works fine)
How can I get async_read_until to work properly?
How are you specifying the delimiter? How are you extracting the data from the streambuf once the operation finishes? It works for me when I use a single char delimiter of '\0', and the implementation of async_read_until doesn't have any special treatment for '\0'. Cheers, Chris

I've since found the root of the problem -- and it has nothing to do with the delim If I have a client send data to the server (which is using async_read_until) If that client sends in a tight for-loop -- async_read_until returns garbled data. If I put even the smallest delays in the loop, the server responds perfectly The server code I am using is the async chat server off of boost.org thanks, billy On Tue, Apr 1, 2008 at 7:16 PM, Christopher Kohlhoff <chris@kohlhoff.com> wrote:
Billy Chasen wrote:
I'm creating a server using boost:asio and am receiving data that ends with a \0 char (from flash sockets if you're curious)
async_read_until seems to not like this as the delimiter. (If I switch to a diff delim like \r\n it works fine)
How can I get async_read_until to work properly?
How are you specifying the delimiter? How are you extracting the data from the streambuf once the operation finishes?
It works for me when I use a single char delimiter of '\0', and the implementation of async_read_until doesn't have any special treatment for '\0'.
Cheers, Chris
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Billy Chasen wrote:
If I have a client send data to the server (which is using async_read_until)
If that client sends in a tight for-loop -- async_read_until returns garbled data.
If I put even the smallest delays in the loop, the server responds perfectly
Sounds suspiciously like a bug in the client. Does the client wait for each send to complete before starting the next one? Please illustrate how the "tight for-loop" works with some code. Cheers, Chris

A faulty client shouldn't mess up a server (I'm trying to build a robust server) I changed the async_read_until calls to async_read_some and now it works perfectly The client purposely wasn't waiting -- it just kept sending data (simulating a bad client) On Fri, Apr 4, 2008 at 3:39 AM, Christopher Kohlhoff <chris@kohlhoff.com> wrote:
Billy Chasen wrote:
If I have a client send data to the server (which is using async_read_until)
If that client sends in a tight for-loop -- async_read_until returns garbled data.
If I put even the smallest delays in the loop, the server responds perfectly
Sounds suspiciously like a bug in the client. Does the client wait for each send to complete before starting the next one? Please illustrate how the "tight for-loop" works with some code.
Cheers, Chris
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Billy Chasen
-
Christopher Kohlhoff