c# - Async Socket reading multiple messages as one -


in "client" have following piece of code:

socket.send(asciiencoding.utf8.getbytes("test0"), socketflags.none); socket.send(asciiencoding.utf8.getbytes("test1"), socketflags.none); socket.send(asciiencoding.utf8.getbytes("test2"), socketflags.none); 

in "server" have following:

public void readcallback(iasyncresult ar) {      stateobject state = (stateobject)ar.asyncstate;      socket handler = state.worksocket;       int read = handler.endreceive(ar);       if (read > 0)      {         string aux = encoding.ascii.getstring(state.buffer, 0, read);         //rest of code... 

my problem is: aux "test0test1test2"... expecting readcallback called 3 times, 1 each send... being called once... have make readcallback behave expected?

i using tcpclient socket type , had problem. has nagle algorithm. able solve problem setting nodelay property true, allows data sent if buffer not yet full.

edit: after reading question again, not sure have same problem did. sending commands device reading response data. trying do, or trying see sent?


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -