开发者

Higher-level socket functions

I have a typical network protocol consisting of typical message stream (32-bit length field + variable-length body) and I want to read messages asynchronously from a TCP socket.

However C# seems to provide a rather low-level API: I still have to allocate buffers, track the written offset and data length by hand, and maintain state between separate calls to read length and body like in the bad old days of C.

Are there any higher-level functions that I can try out before diving into writing tedious asynchronous stateful code? (no third开发者_JS百科-party libraries).


Nothing built-in, no. In fact I can't think of any 3rd party libs for this either. I haven't tried, but it occurs that C# 5 may offer some language-level shiny here. The other option is to use a separate thread that reads synchronously, but that then uses a thread instead of IO completion ports.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜