Skip to content

Commit

Permalink
Test IO timeout by setting setsockopt on MacOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Mar 25, 2024
1 parent 661229a commit 0be537a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib_fiber/samples/setsockopt/echo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

static void set_timeout(ACL_VSTREAM *cstream, int rw_timeout)
{
struct timeval tm;
tm.tv_sec = rw_timeout;
tm.tv_usec = 0;

#if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64)
if (setsockopt(ACL_VSTREAM_SOCK(cstream), SOL_SOCKET,
SO_RCVTIMEO, &__rw_timeout, sizeof(__rw_timeout)) < 0) {
SO_RCVTIMEO, &rw_timeout, sizeof(rw_timeout)) < 0) {
#else
struct timeval tm;
tm.tv_sec = rw_timeout;
tm.tv_usec = 0;
if (setsockopt(ACL_VSTREAM_SOCK(cstream), SOL_SOCKET,
SO_RCVTIMEO, &tm, sizeof(tm)) < 0) {
#endif
Expand Down

0 comments on commit 0be537a

Please sign in to comment.