leak_handler() —— polling to receive packet
| 235 | } |
| 236 | // leak_handler() —— polling to receive packet |
| 237 | int leak_handler(int fd) |
| 238 | { |
| 239 | char buf[4096] = {}; |
| 240 | char send_back[] = "MSG_OK"; |
| 241 | struct sockaddr_in client_addr = {}; |
| 242 | socklen_t client_addr_size = sizeof client_addr; |
| 243 | size_t conn_id = 0; |
| 244 | |
| 245 | for (;;) { |
| 246 | int len = recvfrom(fd, buf, sizeof buf - 1, 0, (struct sockaddr*)&client_addr, &client_addr_size); |
| 247 | if (len <= 0) |
| 248 | error("listener receive failed..\n"); |
| 249 | |
| 250 | sendto(fd, send_back, sizeof(send_back), 0, (struct sockaddr*)&client_addr, client_addr_size); |
| 251 | } |
| 252 | |
| 253 | close(fd); |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | void* new_stack; |
| 258 |