C# und Netzwerk
Auch noch wichtig
You are calling ReadToEnd on the receiver - however, the sender has not said that it has finished sending - the sender only closes the stream etc after the incoming message that will never come; basically, you've deadlocked yourself. There are many ways to approach this type of problem, including: using a length-prefix to a message so the receiver knows how much data to expect in advance (and can limit itself accordingly) using a terminator to a message (maybe a cr/lf) so the receiver knows it has reached the end of a message; for a text protocol, ReadLine may then be useful closing the outbound stream the last is simple if you are only sending one message; just use: socket.Shutdown(SocketShutdown.Send); after sending the message, and the receiver will know it isn't going to get any more data on the socket. Note also that you must clear down things like the crypto stream before doing this, to ensure the data is actually all sent (and not buffered and lost). Personally, I tend to use the first option (length prefix), mainly because I'm usually dealing in multi-message binary protocols.
Offensichtlich bedeutet ein NegotiateStream.EndRead nicht, dass die Nachricht auch als abgeschlossen interpretiert wird, sondern lediglich, dass der Buffer soweit es geht gefüllt wird. Wenn man mit BeginRead loslegt, obwohl der Absender nix mehr schickt, landet man in einer Deadlock!