sslstream

Read SslStream continuously in C# Web MVC 5 project

我只是一个虾纸丫 提交于 2021-02-18 18:43:56
问题 tl;dr: "I would like to read an SslStream continuously in C# but I can't figure out the best way." Some background: I'm getting stock data from a stream that I would like to present in a web interface. The stream sends a heartbeat every 5 seconds and you can also subscribe/unsubscribe to stock prices and news etc. https://api.test.nordnet.se/next/2/api-docs/docs/feeds Currently I'm using SslTcpClient from MSDN example to read and write to the stream and it works OK. https://msdn.microsoft.com

SslStream equivalent of TcpClient.Available?

岁酱吖の 提交于 2021-02-07 05:48:05
问题 Based on the advice of @Len-Holgate in this question, I'm asynchronously requesting 0-byte reads, and in the callback, accept bytes the available bytes with synchronous reads, since I know the data is available and won't block. This seems so efficient and wonderful. But then I add the option for SslStream, and the approach falls apart. The zero-byte read is fine, but the SslStream decrypts the bytes, leaving a zero byte-count in the TcpClient's buffer (appropriately so), and I cannot

Does SslStream.Dispose dispose its inner stream

匆匆过客 提交于 2021-02-05 12:11:28
问题 I use NetworkStream with sockets in an SslStream socket server as follows: stream = new NetworkStream(socket, true); sslStream = new SslStream(stream, false); My question is, if when I call sslStream.Dispose() , will the SslStream dispose/close its inner stream and its socket too? Or do I need to explicitly close all three resources with sslStream.Close() , stream.Close() and socket.Close() ? 回答1: If possible, you should use C#'s using construct to dispose the stream 'automatically' after use

Does SslStream.Dispose dispose its inner stream

谁说我不能喝 提交于 2021-02-05 12:09:29
问题 I use NetworkStream with sockets in an SslStream socket server as follows: stream = new NetworkStream(socket, true); sslStream = new SslStream(stream, false); My question is, if when I call sslStream.Dispose() , will the SslStream dispose/close its inner stream and its socket too? Or do I need to explicitly close all three resources with sslStream.Close() , stream.Close() and socket.Close() ? 回答1: If possible, you should use C#'s using construct to dispose the stream 'automatically' after use

Does SslStream.Dispose dispose its inner stream

天大地大妈咪最大 提交于 2021-02-05 12:05:12
问题 I use NetworkStream with sockets in an SslStream socket server as follows: stream = new NetworkStream(socket, true); sslStream = new SslStream(stream, false); My question is, if when I call sslStream.Dispose() , will the SslStream dispose/close its inner stream and its socket too? Or do I need to explicitly close all three resources with sslStream.Close() , stream.Close() and socket.Close() ? 回答1: If possible, you should use C#'s using construct to dispose the stream 'automatically' after use

Reset TCP connection if server closes/crashes mid connection

风格不统一 提交于 2020-02-07 12:29:30
问题 I have a tcp connection like follows: public void ConnectToServer() { string mac = GetUID(); while(true) { try { tcpClient = new TcpClient("xx.x.xx.xxx", xxxx); networkstream = new SslStream(tcpClient.GetStream()); networkstream.AuthenticateAsClient("xx.x.xx.xxx"); networkstream.Write(Encoding.UTF8.GetBytes("0002:" + mac + "\r\n")); networkstream.Flush(); string serverMessage = ReadMessage(networkstream); Console.WriteLine("MESSAGE FROM SERVER: " + serverMessage); } catch (Exception e) {