networkstream

Parsing data from a network stream?

[亡魂溺海] 提交于 2021-02-08 07:49:24
问题 Recently I started working with sockets. I realized that when reading from a network stream, you can not know how much data is coming in. So either you know in advance how many bytes have to be recieved or you know which bytes . Since I am currently trying to implement a C# WebSocket server I need to process HTTP requests. A HTTP request can have arbitrary length, so knowing in advance how many bytes is out of the question. But a HTTP request always has a certain format. It starts with the

Parsing data from a network stream?

醉酒当歌 提交于 2021-02-08 07:47:05
问题 Recently I started working with sockets. I realized that when reading from a network stream, you can not know how much data is coming in. So either you know in advance how many bytes have to be recieved or you know which bytes . Since I am currently trying to implement a C# WebSocket server I need to process HTTP requests. A HTTP request can have arbitrary length, so knowing in advance how many bytes is out of the question. But a HTTP request always has a certain format. It starts with the

How to set TCPListener to always listen and when new connection discard current

ぐ巨炮叔叔 提交于 2020-03-19 14:42:55
问题 I want to admit I'm not the strongest in c# and I have developed this program by looking at several tutorials, I would appreciate a lot if you can be detailed in your answer. I would like my TCP Server to always listening for incoming connections and when a new TCP Client connects, I want it to discard the old connection and use the new one. I have tried to implement this answer; https://stackoverflow.com/a/19387431/3540143 but my issue is the fact that when I'm simulating a TCP client, but

How to set TCPListener to always listen and when new connection discard current

亡梦爱人 提交于 2020-03-19 14:37:06
问题 I want to admit I'm not the strongest in c# and I have developed this program by looking at several tutorials, I would appreciate a lot if you can be detailed in your answer. I would like my TCP Server to always listening for incoming connections and when a new TCP Client connects, I want it to discard the old connection and use the new one. I have tried to implement this answer; https://stackoverflow.com/a/19387431/3540143 but my issue is the fact that when I'm simulating a TCP client, but

How to set TCPListener to always listen and when new connection discard current

无人久伴 提交于 2020-03-19 14:36:32
问题 I want to admit I'm not the strongest in c# and I have developed this program by looking at several tutorials, I would appreciate a lot if you can be detailed in your answer. I would like my TCP Server to always listening for incoming connections and when a new TCP Client connects, I want it to discard the old connection and use the new one. I have tried to implement this answer; https://stackoverflow.com/a/19387431/3540143 but my issue is the fact that when I'm simulating a TCP client, but

How to set TCPListener to always listen and when new connection discard current

有些话、适合烂在心里 提交于 2020-03-19 14:36:31
问题 I want to admit I'm not the strongest in c# and I have developed this program by looking at several tutorials, I would appreciate a lot if you can be detailed in your answer. I would like my TCP Server to always listening for incoming connections and when a new TCP Client connects, I want it to discard the old connection and use the new one. I have tried to implement this answer; https://stackoverflow.com/a/19387431/3540143 but my issue is the fact that when I'm simulating a TCP client, but

Alternative to NetworkStream.Read that indicates remote host has closed the connection?

末鹿安然 提交于 2020-01-22 06:02:12
问题 With regards to handling a TCP/IP connection using the TcpClient class, is there an alternative for checking whether the remote host has closed the connection other than waiting for the NetworkStream.Read method to return a 0? 回答1: You can use IOControlCode.KeepAliveValues on the TcpClient.Client to guarantee that a keep-alive check is made at least on the specified interval and then check the TcpClient.Client.Connected property. An example how to use it: struct tcp_keepalive { public int

Alternative to NetworkStream.Read that indicates remote host has closed the connection?

佐手、 提交于 2020-01-22 06:01:08
问题 With regards to handling a TCP/IP connection using the TcpClient class, is there an alternative for checking whether the remote host has closed the connection other than waiting for the NetworkStream.Read method to return a 0? 回答1: You can use IOControlCode.KeepAliveValues on the TcpClient.Client to guarantee that a keep-alive check is made at least on the specified interval and then check the TcpClient.Client.Connected property. An example how to use it: struct tcp_keepalive { public int

Sending message from server and receive from the client end

本小妞迷上赌 提交于 2020-01-17 05:01:11
问题 Here is a sample server program written in c# which receives an id from a client. My sample code is given below. I want to send a string array to client and display is on the client console. The sample array string can be: string[] arr1 = new string[] { "one", "two", "three" }; What additional code I need to add with the following server and client code? using System; using System.Net; using System.Net.Sockets; using System.Text; namespace server { class Program { static void Main(string[]

Is it possible to use an http url as your source location of a Source Filter in DirectShow .Net?

做~自己de王妃 提交于 2020-01-15 08:41:26
问题 I'm using the DirectShow.Net Library to create a filter graph that streams video by using an http address and the WM Asf Writer. Then on the webpage I'm able to use the object element to render the video feed in a Windows Media Player object. So now I'm curious if it is possible to read from that http address with some type of FilterSource. I have seen that some people use the AsyncReader as an IBaseFilter, and then casting it as an IFileSourceFilter and calling the load method and passing it