c# - StreamSocket : datareader.LoadAsync waits infinte even when data is avaialbe -
i have following code in windows phone 8 app.
//connection code, done during app start socket = new streamsocket(); await socket.connectasync(serverhostname, servicename); datareader = new datareader(socket.inputstream); datareader.inputstreamoptions = inputstreamoptions.partial; datawriter = new datawriter(socket.outputstream);
after connection established, have thread checks incoming network packets
await datareader.loadasync(2048); datareader.readbytes(buffer); ----------
workflow follows
- phone connects server using socket.connectasync
- server responds initial message (phone receives in datareader.loadasync function)
- phone sends 'business specific' request
- server replies 'business specific' response (problem lies here. phone doesn't receive reply server @ of times).
there no scenario difference between working state' , 'non working state'.
so tried debug this. put breakpoint datareader.loadasync , saw execution waits infinitely @ call.
to make sure server sending data properly, ran app in windows phone emulator , ran wireshark network analyzer in pc. see packets being received ip address of phone.
anyone has hints on why datareader.loadasync function call doesn't return @ all, when there data ready read in socket?
"according documentation when using inputstreamoptions.partial, should use unconsummedbufferlength instead of hardcoded value"
that sample seems broken.
"await reader.loadasync(reader.unconsumedbufferlength);" equivalent to
await reader.loadasync(0); , it's not possible read data, since have no buffer read from.
i'm testing , seems "reader.inputstreamoptions = partial;" has no effect @ all. workaround lower read timeout.
Comments
Post a Comment