MCPcopy Create free account
hub / github.com/acl-dev/acl / echo_client

Function echo_client

lib_fiber/samples-c/test/client2/main.c:28–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26static struct timeval __begin;
27
28static void echo_client(int fd)
29{
30 char buf[8192];
31 int ret, i;
32 const char *str = "hello world\r\n";
33
34 for (i = 0; i < __max_loop; i++) {
35 if (write(fd, str, strlen(str)) <= 0) {
36 printf("write error: %s\r\n", strerror(errno));
37 break;
38 }
39
40 if (!__read_data) {
41 __total_count++;
42 if (i % 10000 == 0)
43 printf("fiber-%d: total %lld, curr %d\r\n",
44 acl_fiber_self(), __total_count, i);
45 if (__total_count % 10000 == 0)
46 acl_fiber_yield();
47 continue;
48 }
49
50 ret = read(fd, buf, sizeof(buf));
51 if (ret <= 0) {
52 printf("read error: %s\r\n", strerror(errno));
53 break;
54 }
55
56 __total_count++;
57 }
58
59 close(fd);
60}
61
62static void fiber_connect(ACL_FIBER *fiber acl_unused, void *ctx acl_unused)
63{

Callers 1

fiber_connectFunction · 0.70

Calls 5

writeFunction · 0.50
acl_fiber_selfFunction · 0.50
acl_fiber_yieldFunction · 0.50
readFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…