Skip to content

Commit

Permalink
Change cast to work on Windows where timeval is defined differently f…
Browse files Browse the repository at this point in the history
…rom Linux
  • Loading branch information
MarkRivers committed Nov 5, 2024
1 parent 56f1645 commit 6807d4f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions asyn/drvAsynSerial/drvAsynIPPort.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,15 @@ connectIt(void *drvPvt, asynUser *pasynUser)
struct timeval saveTV, connectTV;
socklen_t svlen = sizeof saveTV;
pasynManager->getAutoConnectTimeout(&connectTimeout);
connectTV.tv_sec = (time_t)connectTimeout;
connectTV.tv_usec = (suseconds_t)((connectTimeout - connectTV.tv_sec)*1000000);
asynPrint(pasynUser, ASYN_TRACE_ERROR, "Calling setsockopt SO_SNDTIMEO tv_sec=%d tv_usec=%d\n", connectTV.tv_sec, connectTV.tv_usec);
connectTV.tv_sec = (long)connectTimeout;
connectTV.tv_usec = (long)((connectTimeout - connectTV.tv_sec)*1000000);
if (getsockopt (fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&saveTV, &svlen) < 0) {
asynPrint(pasynUser, ASYN_TRACE_ERROR, "connectIt, error calling getsockopt for SO_RECVTIMEO: %s\n", strerror(SOCKERRNO));
}
if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&connectTV, sizeof connectTV) < 0) {
asynPrint(pasynUser, ASYN_TRACE_ERROR, "connectIt, error calling setsockopt for SO_RECVTIMEO: %s\n", strerror(SOCKERRNO));
}
asynPrint(pasynUser, ASYN_TRACE_ERROR, "connectIt, calling connect()\n");
if (connect(fd, &tty->farAddr.oa.sa, (int)tty->farAddrSize) < 0) {
asynPrint(pasynUser, ASYN_TRACE_ERROR, "connectIt, connect returned error: %s\n", strerror(SOCKERRNO));
epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
"Can't connect to %s: %s",
tty->IPDeviceName, strerror(SOCKERRNO));
Expand Down

0 comments on commit 6807d4f

Please sign in to comment.