Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
dữ liệu sẽ đọc các byte còn lại "vui mừng", và bất kỳ dữ liệu theo byte khẩn cấp, nếu có tồn tại. Ngay cả khi dữ liệu out-of-band không được đọc trong các chức năng xử lý tín hiệu, chỉ có các byte 'vui mừng và dữ liệu nonurgent tiếp theo sẽ được đọc, nếu có. | data will read the remaining bytes rejoice and any data that follows the urgent byte if any exists. Even if the out-of-band data was not read in the signal handling function only the bytes rejoice and subsequent nonurgent data would be read if any. The d byte would be prevented from being returned in the normal in-band data because it has been identified as out-of-band data. Urgent Mode When tcp_stdurg 1 Space does not permit us to dwell on this case but a few comments are worthwhile. When tcp_stdurg 1 a strange thing often happens urgent mode is often entered and its corresponding urgent pointer is received without any corresponding urgent data to be read. If the urgent pointer happens to be at the end of the last data byte included within the packet then there might not be any following byte received. The urgent data byte might follow in a subsequent packet. For this reason when this mode of operation is used the recv 2 call with the MSG_OOB flag set does not necessarily return an out-ofband byte for TCP when the signal SIGURG is raised. Tip When tcp_stdurg 1 under Linux a recv 2 call will return the errno value EAGAIN when no urgent data is available to read. Some other UNIX implementations BSD UNIX for example return the errno value EWOULDBLOCK instead. To handle the situation where the urgent data byte was unavailable you must perform the following remember this applies only when tcp_stdurg 1 1. Record the SIGURG event in a flag say a variable named urg_mode 1 . 2. Return from your signal handler. 3. Continue to read in-band data within your application. 4. When the urg_mode value is true try to read some out-ofband data by using recv 2 and the and the MSG_OOB flag bit. 5. If step 4 yields data then set urg_mode 0 and return to normal processing. Repeat step 3. Linux Socket Programming by Example - Warren W. Gay 359 6. If step 4 does not yield any out-of-band data continue processing while leaving urg_mode set true. Repeat step 3. Again it must be emphasized .