1. Socket
- Socket
- IP 주소 (Internet Protocol Address)
- 포트(Port)
- IP 주소와 Port의 결합
2. TCP
- TCP (Transmission Control Protocol)
- 특징
- TCP 헤더 구조
- TCP Connection/Termination
3. Observer Pattern
실습: Java Socket
1. Socket
Socket 통신: 네트워크 상에서 두 프로그램 간의 통신을 가능하게 하는 기술.
Socket
- IP 주소와 Port 번호로 구성.
- 클라이언트와 서버 간의 데이터 전송을 담당.
- 종류
- TCP Socket: 신뢰성 있는 Connection-Oriented Protocol. -> Virtual Circuit 사용.
- UDP Socket: Connectionless-Oriented Protocol. -> Datagram 사용.
IP 주소 (Internet Protocol Address)
- 네트워크 상에서 장치를 식별하는 고유한 주소.
- IPv4: 32bit 주소 체계
- IPv6: 128bit 주소 체계
포트(Port)
- IP 주소와 결합되어, 특정 네트워크 서비스나 Application을 식별하는 숫자.
- Well-known Ports: 0~1023, 표준 서비스에 할당. ex) HTTP(80), HTTPS(443), FTP(21) ...
- Registered Ports: 1024~49151, 특정 Application이나 서비스에 할당.
- Dynamic/Private Ports: 49152~65535, 임시 연결에 사용.
IP 주소와 Port의 결합
- IP 주소와 Port 번호는 함께 사용되어 네트워크 상에서 특정 Application을 식별하고 통신 수행.
ex) 127.0.01:8080 - IP 주소 '127.0.01'의 port 번호 '8080'에서 실행되는 App을 의미.
2. TCP
TCP (Transmission Control Protocol)
- 신뢰성 있는 데이터 전송을 보장하는 Connection-Oriented Protocol.
특징
- 연결 지향(Connection-oriented)
- TCP는 데이터 전송 전에 sender와 receiver의 연결을 설정.
- 신뢰성(Reliability)
- 데이터가 손실되거나 손상된 경우, 재전송을 통헤 데이터의 무결성을 보장.
- 흐름 제어(Flow Control)
- Sender와 Receiver의 처리 능력을 초과하지 않도록 데이터 전송 속도 조절.
- 혼잡 제어(Congestion Control)
- 네트워크 혼잡 방지를 위해 데이터 전송 속도 조절.
TCP 헤더 구조
출처: https://en.wikipedia.org/wiki/Transmission_Control_Protocol
Transmission Control Protocol - Wikipedia
From Wikipedia, the free encyclopedia Principal protocol used to stream data across an IP network The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in wh
en.wikipedia.org
TCP Connection/Termination
- TCP Connection - 3 way handshake
- SYN
- SYN-ACK
- ACK
- TCP Termination - 4 way handshake
- FIN
- ACK
- FIN
- ACK
* Java에서 TCP 역할을 Class로 만든 것이 ServerSocket, Socket Class다.
* Java의 InetAddress Class: https://needneo.tistory.com/205
3. Observer Pattern
옵저버(관찰자)들이 관찰하고 있는 대상자의 상태가 변화가 있을 때마다 대상자가 직접 목록의 각 옵저버들에게 통지하고, 옵저버들은 알림을 받아 조치를 취하는 행동 패턴.
💠 옵저버(Observer) 패턴 - 완벽 마스터하기
Observer Pattern 옵저버 패턴(Observer Pattern)은 옵저버(관찰자)들이 관찰하고 있는 대상자의 상태가 변화가 있을 때마다 대상자는 직접 목록의 각 관찰자들에게 통지하고, 관찰자들은 알림을 받아 조
inpa.tistory.com
실습: Java Socket
https://github.com/Joo-v7/NHN-Academy-Network-Socket
GitHub - Joo-v7/NHN-Academy-Network-Socket
Contribute to Joo-v7/NHN-Academy-Network-Socket development by creating an account on GitHub.
github.com
'Thread - Network' 카테고리의 다른 글
[Network] HTTP와 GET / POST 방식 (0) | 2024.10.05 |
---|---|
[Thread] Java Thread (0) | 2024.09.11 |