TAILIEUCHUNG - TCP/IP Sockets in C# Practical Guide for Programmers phần 10

cấu trúc ổ cắm của TcpListener. Lưu ý rằng TcpListener bản thân không thay đổi trạng thái, cũng không phải thực hiện bất kỳ thay đổi thông tin địa chỉ của nó. Ngoài việc tạo ra một cấu trúc socket mới cơ bản, phía máy chủ TCP thực hiện gửi một thông báo thừa nhận cái bắt tay TCP lại cho khách hàng. | Underlying implementation Incoming connection request from P TcpListener Socket Structure Listening Listening Listening Local port Local IP Remote port Remote IP Q Local port Local IP Remote port Remote IP Q Local port Local IP Remote port Remote IP Q 1 Create new structure and continue handshake Associated Socket TcpClient Structure Connecting Handshake completes Established Local port Local IP Remote port Remote IP Q Local port Local IP Remote port Remote IP Q P P Incoming connection request processing. Figure TCP Socket Life Cycle 159 160 Chapter 5 Under the Hood the socket structure of the TcpListener. Note that the TcpListener itself does not change state nor does any of its address information change. In addition to creating a new underlying socket structure the server-side TCP implementation sends an acknowledging TCP handshake message back to the client. However the server TCP does not consider the handshake complete until the third message of the 3-way handshake is received from the client. When that message eventually arrives the new structure s state is set to Established and it is then and only then moved to a list of socket structures associated with the TcpListener structure which represent established connections ready to be Accept ed via the TcpListener. If the third handshake message fails to arrive eventually the Connecting structure is deleted. Now we can consider in Figure what happens when the server program calls the TcpListener Socket s Accept method. The call unblocks as soon as there is something in its associated list of socket structures for new connections. Note that this list may already be nonempty when Accept is called. At that time one of the new connection structures is removed from the list and an instance of Socket or TcpClient is created for it and returned as the result of the Accept . It is important to note that each structure in the TcpListener s associated list represents a

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.