일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 파이썬 데이터분석
- 플레이프레임워크
- 주키퍼
- 파이썬 동시성
- CORDA
- Play2
- play2 강좌
- Play2 로 웹 개발
- Hyperledger fabric gossip protocol
- 블록체인
- 스칼라
- Golang
- 그라파나
- 이더리움
- 파이썬
- Akka
- 스위프트
- Adapter 패턴
- 파이썬 머신러닝
- Actor
- 하이브리드앱
- 하이퍼레저 패브릭
- 스칼라 동시성
- akka 강좌
- 안드로이드 웹뷰
- 엔터프라이즈 블록체인
- hyperledger fabric
- 스칼라 강좌
- play 강좌
- 파이썬 강좌
- Today
- Total
HAMA 블로그
Half close socket 이란 본문
Half Close 란?
half-closed connection 을 말하는데 TCP 특성상 양쪽에서 받고 보내는 연결이 2중이 되는데 , 한 쪽만
닫는것을 말합니다. 종료시에 보통 입력 스트림을 살리고 전송 스트림은 닫습니다.
When shutting down a TCP connection, something curious occurs. The TCP connection is duplex: data flows in both directions. And it's created in this manner -- it is impossible to create "half" a TCP connection, that would let data flow only from one end to the other. The SYN/ACK handshaking creates both directions at once or fails. Of course, your program might use the TCP connection to stream data in only one direction. But both directions are there...
When closing the connection, something else occurs. A party wishing to close its side of the TCP connection sends a FIN (i.e. a header with this bit set, along with any of the usual ACKs etc.). Like a SYN at the beginning of the connection, the FIN consumes a TCP sequence number, so it can be ACKed. And after the other party ACKs, the connection is half-closed! The party which sent the FIN can no longer send data -- but the other party may continue to send data.To close the TCP stream fully, both sides must send a FIN for "their" half of the connection. What possible use is a half-open connection?
In fact, a great deal of use. TCP streams share a great deal of intended functionality with UN*X pipes. In particular, it is often useful to think of sending a FIN in the same way as sending an EOF to the other side. Many processes can only compute their output after they finish reading their input. If you wish to connect such a program to a TCP stream, you'll need to denote the end of input in some manner -- and that manner is TCP's FIN.
For instance, suppose we have a program md5sum which computes the MD5 checksum of its input. md5sum reads its entire input, and only then generates output. Suppose further I have a file xyzzy on machinealice, and the program md5sum on machine bob. How can I compute the checksum?
alice% rsh bob md5sum < xyzzy
does the trick.
md5sum cannot produce any output until it knows its read all its input. Thus, no application data will flow from bob to alice until alice sends FIN. As soon as alice sends FIN, rsh on bob knows that its standard input has ended, and closes md5sum's input. Now md5sum can output its application data, which is transmitted on the half-open side of the TCP stream. Immediately following this data comes bob's FIN, closing the other half of the connection.
Without the TCP's half-close, some out of band data would have had to be used, significantly complicating TCP. A half-closed pipe is useful.
http://everything2.com/title/TCP+half-close
'Network' 카테고리의 다른 글
keepalive 란? (0) | 2015.07.22 |
---|---|
SSH 터널링 상세이론 (0) | 2015.07.14 |
홀펀칭 기초 (0) | 2015.07.14 |
와이파이로 기기간 연결 강화한다 (0) | 2015.06.11 |
모바일기기 wifi의 ip주소를 수동으로 설정하기 (0) | 2015.06.11 |