This is Unofficial EPICS BASE Doxygen Site
rtems_util.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Saskatchewan
3 * EPICS BASE Versions 3.13.7
4 * and higher are distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * RTEMS utilitiy routines for EPICS
9  * Author: W. Eric Norum
10  * eric@cls.usask.ca
11  * (306) 966-6055
12  *
13  * Supplies routines that are present in vxWorks but missing in RTEMS.
14  */
15 
16 #include <string.h>
17 #include <netdb.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <sys/time.h>
21 #include <netinet/in.h>
22 
23 /*
24  * Like connect(), but with an explicit timeout
25  */
26 int connectWithTimeout (int sfd,
27  struct sockaddr *addr,
28  int addrlen,
29  struct timeval *timeout)
30 {
31  struct timeval sv;
32  socklen_t svlen = sizeof sv;
33  int ret;
34 
35  if (!timeout)
36  return connect (sfd, addr, addrlen);
37  if (getsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, &svlen) < 0)
38  return -1;
39  if (setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)timeout, sizeof *timeout) < 0)
40  return -1;
41  ret = connect (sfd, addr, addrlen);
42  setsockopt (sfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&sv, sizeof sv);
43  return ret;
44 }
double timeout
Definition: pvutils.cpp:25
int connectWithTimeout(int sfd, struct sockaddr *addr, int addrlen, struct timeval *timeout)
Definition: rtems_util.c:26
BSD and SRV5 Unix timestamp.
Definition: epicsTime.h:52