How To Signal End Of Data Without Closing NetworkStream in C#

前端 未结 2 1288
广开言路
广开言路 2020-12-18 04:10

I have a client application that serializes a object and sends it to a server application. The server should deserialize the object, make changes to it, then serialize it an

2条回答
  •  盖世英雄少女心
    2020-12-18 04:52

    You could use a higher level framework like WCF, or if you are hell-bent on managing your own streams, then don't use ReadToEnd()- use ReadLine() (and have the client send messages as lines), or use Read() and have a special character (a sentinel) represent the end of a message.

提交回复
热议问题