Hard
close() with a 10-second SO_LINGER and its return value
A Linux order gateway uses the code below to decide that a fill report reached the counterparty. The socket is blocking, and no unread inbound data is pending on it. What does close() returning 0 at (1) actually establish?
main.cpp
struct linger lg = { .l_onoff = 1, .l_linger = 10 };
setsockopt(fd, SOL_SOCKET, SO_LINGER, &lg, sizeof(lg));
write(fd, fill_report, len); // returns len
if (close(fd) == 0)
mark_delivered(order_id); // (1)42 of 45 in Networking