/*************************************************************************\ * Copyright (c) 2002 The University of Saskatchewan * SPDX-License-Identifier: EPICS * EPICS Base is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* * RTEMS utility routines for EPICS * Author: W. Eric Norum * eric@cls.usask.ca * (306) 966-6055 * * Supplies routines that are present in vxWorks but missing in RTEMS. */ #include #include #include #include #include #include /* * Like connect(), but with an explicit timeout */ int connectWithTimeout (int sfd, struct sockaddr *addr, int addrlen, struct timeval *timeout) { struct timeval sv; socklen_t svlen = sizeof sv; int ret; if (!timeout) return connect (sfd, addr, addrlen); if (getsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, &svlen) < 0) return -1; if (setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)timeout, sizeof *timeout) < 0) return -1; ret = connect (sfd, addr, addrlen); setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, sizeof sv); return ret; }