如何从tcp端口号C#读取视频

时间:2017-06-23 09:40:33

标签: c# sockets tcp port

我正在尝试从端口号读取视频流,但应用程序似乎冻结在serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);

C#:

private void Form1_Load(object sender, EventArgs e)
{
    msg("Client Started");
    clientSocket.Connect("127.0.0.1", 65200);
    label1.Text = "Client Socket Program - Server Connected ...";
}  

private void button1_Click_1(object sender, EventArgs e)
{
    NetworkStream serverStream = clientSocket.GetStream();
    byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox2.Text + "$");
    serverStream.Write(outStream, 0, outStream.Length);
    serverStream.Flush();

    byte[] inStream = new byte[10025];
    serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
    string returndata = System.Text.Encoding.ASCII.GetString(inStream);
    msg(returndata);
    textBox2.Text = "";
    textBox2.Focus();
}

0 个答案:

没有答案