Linux Socket Programming by Example PHẦN 6

Hạt nhân cuối cùng sẽ quyết định giá trị cuối cùng sẽ được thành lập. Nếu nó là rất quan trọng cho ứng dụng và hạt nhân đồng ý một cách chính xác trên các kích cỡ, các ứng dụng cần lấy các giá trị cuối cùng được thành lập bởi hạt nhân. Điều này được thực hiện với một cuộc gọi tiếp theo. | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 rpn_process FILE tx char buf int z mpz_t t char operation char operand operation strtok buf n r operand strtok NuLL n r if strcmp operation dump rpn_dump tx else if strcmp operation Pop off the result if z rpn_pop t -1 fputs E Nothing to pop n tx else fprintf tx d z m pz_out_str tx 10 t fputc n tx rpn_free t else if strcmp operation Push an operand onto the stack t rpn_alloc if mpz_set_str t operand 10 fprintf tx d n rpn_push t else fputs E Invalid number n tx rpn_free t else Perform an operation z rpn_opr operation if z -1 fprintf tx E Operation failed. n else fprintf tx d n z fflush tx Linux Socket Programming by Example - Warren W. Gay 257 While Listing is quite long only the server concepts within it are important to you here. Consequently only the rpn_process function will be described 1. The rpn_process function is called with the output stream to write to argument tx and the input text line in buf to process line 413 . 2. The variables operation and operand are the parsed operation and operand strings respectively lines 419 to 420 . 3. If the operation is special operation dump the function rpn_dump is called to list the contents of the stack lines 422 to 423 . 4. If step 3 does not apply and if the operation is the value is popped off the stack and returned to the client program lines 425 to 436 . Proceed to step 7. 5. If steps 3 and 4 do not apply and if the operation is the operand value is pushed onto the stack lines 438 to 448 . Proceed to step 7. 6. If steps 3 4 and 5 do not apply all other RPN operations are handled by the function rpn_opr . The result reported back to the client is the stack index value or an error indication lines 454 to 460 . 7. The output is forced to be written to the socket by calling fflush tx in line 462. How the server .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
55    74    2    24-05-2024
Đã 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.