C-why does phpredis need to call poll twice after sending data?

Source: Internet
Author: User
Tags pconnect
{Code ...} the above is the php code, and then I strace it, the result is as follows {code ...} after sending the get command in line 3, poll is called. The timeout value is the value of line 0, 1572, and the value of timeout is 2000. Why do I need to call poll twice...
$host = '127.0.0.1';$port = 8888;$key = 'group:32149904:binding';$redis = new Redis();$redis->pconnect($host, $port);$obj = $redis->get($key);echo $obj, PHP_EOL;

The above is the php code, and then I strace it, the result is as follows:

1565 connect(3, {sa_family=AF_INET, sin_port=htons(6080), sin_addr=inet_addr("10.83.73.168")}, 16) = -1 EINPROGRESS (Operation now in progress)1566 poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLOUT}])1567 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 01568 fcntl(3, F_SETFL, O_RDWR)               = 01569 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 01570 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1571 sendto(3, "*2\r\n$3\r\nGET\r\n$22\r\ngroup:32149904"..., 42, MSG_DONTWAIT, NULL, 0) = 421572 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1573 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLIN}])1574 recvfrom(3, "$44\r\n{\"allyid\":\"60979\",\"appid\":\""..., 8192, MSG_DONTWAIT, NULL, NULL) = 511575 write(1, "{\"allyid\":\"60979\",\"appid\":\"ex_mm"..., 44) = 441576 write(1, "\n", 1)                       = 11577 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1578 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 01579 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1580 sendto(3, "*2\r\n$3\r\nGET\r\n$22\r\ngroup:32149904"..., 42, MSG_DONTWAIT, NULL, 0) = 421581 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1582 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLIN}])1583 recvfrom(3, "$44\r\n{\"allyid\":\"60979\",\"appid\":\""..., 8192, MSG_DONTWAIT, NULL, NULL) = 511584 write(1, "{\"allyid\":\"60979\",\"appid\":\"ex_mm"..., 44) = 441585 write(1, "\n", 1)                       = 1

After sending the get command in line 3, poll is called. The timeout value is the value of line 0, 1572, and the value of timeout is 2000.

Why do I need to call poll twice? Can I call it only once?

Reply content:
$host = '127.0.0.1';$port = 8888;$key = 'group:32149904:binding';$redis = new Redis();$redis->pconnect($host, $port);$obj = $redis->get($key);echo $obj, PHP_EOL;

The above is the php code, and then I strace it, the result is as follows:

1565 connect(3, {sa_family=AF_INET, sin_port=htons(6080), sin_addr=inet_addr("10.83.73.168")}, 16) = -1 EINPROGRESS (Operation now in progress)1566 poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLOUT}])1567 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 01568 fcntl(3, F_SETFL, O_RDWR)               = 01569 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 01570 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1571 sendto(3, "*2\r\n$3\r\nGET\r\n$22\r\ngroup:32149904"..., 42, MSG_DONTWAIT, NULL, 0) = 421572 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1573 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLIN}])1574 recvfrom(3, "$44\r\n{\"allyid\":\"60979\",\"appid\":\""..., 8192, MSG_DONTWAIT, NULL, NULL) = 511575 write(1, "{\"allyid\":\"60979\",\"appid\":\"ex_mm"..., 44) = 441576 write(1, "\n", 1)                       = 11577 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1578 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 01579 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1580 sendto(3, "*2\r\n$3\r\nGET\r\n$22\r\ngroup:32149904"..., 42, MSG_DONTWAIT, NULL, 0) = 421581 poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)1582 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 2000) = 1 ([{fd=3, revents=POLLIN}])1583 recvfrom(3, "$44\r\n{\"allyid\":\"60979\",\"appid\":\""..., 8192, MSG_DONTWAIT, NULL, NULL) = 511584 write(1, "{\"allyid\":\"60979\",\"appid\":\"ex_mm"..., 44) = 441585 write(1, "\n", 1)                       = 1

After sending the get command in line 3, poll is called. The timeout value is the value of line 0, 1572, and the value of timeout is 2000.

Why do I need to call poll twice? Can I call it only once?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.