This is Unofficial EPICS BASE Doxygen Site
rtems_util.c File Reference
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
+ Include dependency graph for rtems_util.c:

Go to the source code of this file.

Functions

int connectWithTimeout (int sfd, struct sockaddr *addr, int addrlen, struct timeval *timeout)
 

Function Documentation

int connectWithTimeout ( int  sfd,
struct sockaddr *  addr,
int  addrlen,
struct timeval timeout 
)

Definition at line 26 of file rtems_util.c.

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 }
BSD and SRV5 Unix timestamp.
Definition: epicsTime.h:52