This is Unofficial EPICS BASE Doxygen Site
osdSockAddrReuse.cpp
Go to the documentation of this file.
1 
2 /*************************************************************************\
3 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
4 * National Laboratory.
5 * Copyright (c) 2002 The Regents of the University of California, as
6 * Operator of Los Alamos National Laboratory.
7 * EPICS BASE Versions 3.13.7
8 * and higher are distributed subject to a Software License Agreement found
9 * in file LICENSE that is included with this distribution.
10 \*************************************************************************/
11 
12 /*
13  * Author: Jeff Hill
14  */
15 #if defined(__rtems__)
16 # define __BSD_VISIBLE 1
17 #endif
18 
19 #include "osiSock.h"
20 #include "errlog.h"
21 
22 LIBCOM_API void epicsStdCall
24 {
25  int yes = true;
26  int status;
27  status = setsockopt ( s, SOL_SOCKET, SO_REUSEADDR,
28  (char *) & yes, sizeof ( yes ) );
29  if ( status < 0 ) {
30  errlogPrintf (
31  "epicsSocketEnableAddressReuseDuringTimeWaitState: "
32  "unable to set SO_REUSEADDR?\n");
33  }
34 }
35 
36 static
37 void setfanout(SOCKET s, int opt, const char *optname)
38 {
39  int yes = true;
40  int status;
41  status = setsockopt ( s, SOL_SOCKET, opt,
42  (char *) & yes, sizeof ( yes ) );
43  if ( status < 0 ) {
44  errlogPrintf (
45  "epicsSocketEnablePortUseForDatagramFanout: "
46  "unable to set %s?\n", optname);
47  }
48 }
49 
51 {
52 #define DOIT(sock, opt) setfanout(sock, opt, #opt)
53 #ifdef SO_REUSEPORT
54  DOIT(s, SO_REUSEPORT);
55 #endif
56  DOIT(s, SO_REUSEADDR);
57 #undef DOIT
58 }
pvd::Status status
void epicsStdCall epicsSocketEnableAddressUseForDatagramFanout(SOCKET s)
LIBCOM_API void epicsStdCall epicsSocketEnableAddressReuseDuringTimeWaitState(SOCKET s)
int SOCKET
Definition: osdSock.h:31
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
#define DOIT(sock, opt)