Skip to content

Commit

Permalink
Fix is_connected
Browse files Browse the repository at this point in the history
  • Loading branch information
shiveshkhaitan committed Sep 1, 2019
1 parent 8fa1021 commit ef16fa5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/socket_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ void SocketCAN::init()
return;
}

int error = 0;
socklen_t len = sizeof (error);
int retval = getsockopt (socket_, SOL_SOCKET, SO_ERROR, &error, &len);
if (retval != 0) {
/* there was a problem getting the error code */
printf("Error getting socket error code: %s\n", strerror(retval));
return;
}

if (error != 0) {
/* socket has a non zero error status */
printf("Socket error: %s\n", strerror(error));
return;
}

struct timeval timeout{};
timeout.tv_sec = (timeout_ / 1000);
timeout.tv_usec = (timeout_ % 1000) * 1000;
Expand Down

0 comments on commit ef16fa5

Please sign in to comment.