TAILIEUCHUNG - Internetworking with TCP/IP- P49

Internetworking with TCP/IP- P49: TCP/IP has accommodated change well. The basic technology has survived nearly two decades of exponential growth and the associated increases in traffic. The protocols have worked over new high-speed network technologies, and the design has handled applications that could not be imagined in the original design. Of course, the entire protocol suite has not remained static. New protocols have been deployed, and new techniques have been developed to adapt existing protocols to new network technologies | Sec. An Example Server 439 Get our own host information gethostname localhost MAXB09INAME if hp gethosttyname localhost NULL fprintf stderr s cannot get local host info n rename exit l Put the WHOIS socket nutter and our address info into the socket structure sp- s_port bcopy char hp- h_addr char hp- h_length hp- h_addrtype Allocate an open socket for incoming connections if s socket hp- h_addrtype SOCKJMREAM 0 0 perror socket exit l Bind the socket to the service port so we hear incoming connections if bind s sa sizeof sa 0 perror bind exit l Set znaxinun ccmecticns we will fall behind listen s BACKLOG Go into an infinite loop waiting for new connections whiled i sizeof isa We hang in accept 0 while waiting for new customers if t accept s isa i 0 440 The Socket Interface Chap. 22 perror accept exit l v ois t perform the actual WHDIS service close t Get the WHDIS request from remote host and format a reply. viiois sock int sock struct passwd p char buf BUFSIZ 1 int i Get one line request if i read sock buf BUFSIZ 0 return buf i 0 Null terminate Look up the requested user and format reply if p getpwnam buf NULL strcpyCbuf User not foundXn else sprintf buf s s n p- pw_name p- pw_gecos Return reply write sock buf strlen buf return Summary Because TCP IP protocol software resides inside an operating system the exact interface between an application program and TCP IP protocols depends on the details of the operating system it is not specified by the TCP IP protocol standard. We examined the socket API which was originally designed for BSD UNIX but has become de fac Sec. Summary 441 to a standard used by vendors such as Microsoft. We saw that sockets adopted the UNIX open-read-write-close paradigm. To use TCP a program must create a socket bind addresses to it accept incoming connections and then communicate using the read or write primitives. Finally when finished using a socket the program must close it. In .

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.