Chapter 5 UDP Socket Socket UDP Echo Server

  • Slides: 21
Download presentation
Chapter 5 UDP Socket 소켓 프로그래밍

Chapter 5 UDP Socket 소켓 프로그래밍

Socket 클래스를 이용한 UDP � � � 예제 프로그램 : Echo. Server. UDPSocket. cs,

Socket 클래스를 이용한 UDP � � � 예제 프로그램 : Echo. Server. UDPSocket. cs, Echo. Client. UDPSocket. cs Udp. Client가 아닌 Socket 클래스의 Send. To() 메서드와 Receive. From() 메서드를 활용 하여 UDP Echo 프로그램을 만들 수 있음 데이터 송신 public int Send. To(byte[], End. Point) public int Send. To(byte[], Socket. Flags, End. Point) public int Send. To(byte[], int, Socket. Flags, End. Point) ◦ byte[], int - 보낼 데이터의 바이트 배열과 시작위치(offset), 데이터의 크기 ◦ Socket. Flags - 소켓의 동작을 지정 ◦ End. Point - 원격 호스트 � 데이터 수신 public int int Receive. From(byte[], ref End. Point) Socket. Flags, ref End. Point) int, Socket. Flags, ref End. Point)

멀티캐스팅 � 멀티캐스트 가입/탈퇴를 위한 메서드 ◦ 멀티캐스트 그룹 가입 public void Join. Multicast.

멀티캐스팅 � 멀티캐스트 가입/탈퇴를 위한 메서드 ◦ 멀티캐스트 그룹 가입 public void Join. Multicast. Group(IPAddress) Join. Multicast. Group(int, IPAddress) Join. Multicast. Group(IPAddress, int) Join. Multicast. Group(IPAddress, IPAddress) � 멀티캐스트 그룹에 가입하기 전에 포트 바인딩을 해야 함 � int, IPAddress – interface index, 멀티캐스트 그룹 IP 주소 � Interface index는 같은 링크에 있는 하드웨어를 식별하기 위해 사용 � IPAddress , int – 멀티캐스트 그룹 IP 주소, TTL � TTL(Time to Live)은 멀티캐스팅된 데이터그램에 허용되는 라우터 홉수를 의미, 데이터그램이 지정 된 수를 넘어 라우터를 경유한 경우에 폐기됨 � IPAddress , IPAddress – 멀티캐스트 그룹 IP 주소, 로컬 IP 주소 ◦ 멀티캐스트 그룹 탈퇴 public void Drop. Multicast. Group(IPAddress) public void Drop. Multicast. Group(IPAddress, int) � Int – interface index