TAILIEUCHUNG - Embedded FreeBSD Cookbook phần 6

Các yếu tố sin_len đại diện cho chiều dài của cấu trúc. Sin_family mô tả các địa chỉ gia đình, AF_INET. Sin_port là 16-bit số cổng để kết nối. Các yếu tố sin_addr là một địa chỉ IP 32-bit đại diện cho các máy chủ để kết nối. Tham số thứ ba là chiều dài của cấu trúc thông qua như là tham số sockaddr. Bind trả về 0 nếu thành công, -1 nếu có một lỗi. Các cuộc gọi hệ thống gần | 111 Chapter Six Daemons struct sockaddr in u char sin len u char sin family u short sin port struct in addr sin addr char sin zero 8 The sin_len element represents the length of the structure. The sin_family describes the address family AF_INET. The sin_port is the 16-bit port number to bind. The sin_addr element is a 32-bit IP address that represents the host to connect. The third parameter is the length of the structure passed as the sockaddr parameter. Bind returns 0 if successful and -1 if there is an error. The close System Call When a network service is shut down proper cleanup is recommended. The socket descriptor should be closed using the close system call the same as a file descriptor. include int close int fd The descriptor passed is the socket descriptor returned by the socket system call. The close system call terminates the socket. Close returns 0 on success -1 on error. Server The DIO server we are developing is a connection-based server. A connectionbased application is similar to file IO. A connection is opened with another process and that connection remains with the same process and host for the remainder of the transfer operation. The DIO server operations consist of requests to perform data acquisition operations. The types of requests will be discussed in more detail in the protocol section. The remainder of this section focuses on the socket calls for creating socket connections. The listen System Call Once the server has successfully created a socket it must designate itself willing to listen for incoming requests. Listening on a socket is performed by calling the listen system call. 112 Embedded FreeBSD Cookbook include sys include int listen int s int backlog The first parameter is the socket descriptor returned by the socket system call. The second parameter backlog specifies the maximum number of outstanding connections that may be queued by the server. Listen returns 0 on success or -1 on error. The accept .

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.