C#

[RTSP] TCPClient를 이용하여 OPTIONS 요청 결과 받기

Hwoarang757 2022. 3. 3. 00:20

RTP 패킷에 대한 구조나 개념에 대한 학습 방법을 찾아 보고 있습니다.

 

TCP 전문을 전송하여 OPTIONS 응답에 대한 결과를 받아 보는 테스트를 진행 하였습니다.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace BlockingSocketTest
{
    class Program
    {
        static void Main(string[] args)
        {
            TcpClient client = new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.14.15"),0));
            // RTSP Server 주소 
            client.Connect(new IPEndPoint(IPAddress.Parse("192.168.14.8"), 1935));

            NetworkStream stream = client.GetStream();

            StringBuilder options = new StringBuilder();
            options.AppendLine("OPTIONS * RTSP/1.0");
            options.AppendLine("CSeq: 1");
            options.AppendLine("User-Agent: TestWAS_Server");
            options.AppendLine();
            options.AppendLine();

            byte[] bytes = Encoding.Default.GetBytes(options.ToString());

            stream.Write(bytes,0, bytes.Length );

            byte[] recvByte = new byte[256];

            stream.Read(recvByte, 0, recvByte.Length);
		    // RTSP 응답 Console 에 Write 처리 
            Console.WriteLine(Encoding.Default.GetString(recvByte));
            
            Console.In.ReadLine();
        }
    }
}

실행 결과 입니다

WireShark로 캡쳐 진행 해보았습니다. OPTIONS 요청 패킷을 던졌을때 Dump 입니다.