diff --git a/src/cas/io/bsdSocket/caServerIO.cc b/src/cas/io/bsdSocket/caServerIO.cc index 60cbaf638..baa3abd88 100644 --- a/src/cas/io/bsdSocket/caServerIO.cc +++ b/src/cas/io/bsdSocket/caServerIO.cc @@ -5,6 +5,9 @@ // // // $Log$ +// Revision 1.8 1998/05/29 20:08:20 jhill +// use new sock ioctl() typedef +// // Revision 1.7 1997/08/05 00:47:22 jhill // fixed warnings // @@ -33,6 +36,7 @@ #include "server.h" #include "sigPipeIgnore.h" #include "addrList.h" +#include "bsdSocketResource.h" static char *getToken(const char **ppString, char *pBuf, unsigned bufSIze); @@ -43,6 +47,7 @@ int caServerIO::staticInitialized; // caServerIO::~caServerIO() { + bsdSockRelease(); } // @@ -73,6 +78,10 @@ caStatus caServerIO::init(caServerI &cas) struct sockaddr_in saddr; int autoBeaconAddr; + if (!bsdSockAttach()) { + return S_cas_internal; + } + caServerIO::staticInit(); // @@ -119,14 +128,16 @@ caStatus caServerIO::init(caServerI &cas) int configAddrOnceFlag = TRUE; stat = S_cas_noInterface; while ( (pToken = getToken(&pStr, buf, sizeof(buf))) ) { - saddr.sin_addr.s_addr = inet_addr(pToken); - if (saddr.sin_addr.s_addr == ~0ul) { + int status; + + status = aToIPAddr (pToken, 0u, &saddr); + if (status) { ca_printf( "%s: Parsing '%s'\n", __FILE__, EPICS_CAS_INTF_ADDR_LIST.name); ca_printf( - "\tBad internet address format: '%s'\n", + "\tBad internet address or host name: '%s'\n", pToken); continue; } diff --git a/src/cas/io/bsdSocket/casDGIO.cc b/src/cas/io/bsdSocket/casDGIO.cc index b1d0ddb4b..0bbeee7a2 100644 --- a/src/cas/io/bsdSocket/casDGIO.cc +++ b/src/cas/io/bsdSocket/casDGIO.cc @@ -30,7 +30,7 @@ #include "server.h" #include "dgInBufIL.h" // in line func for dgInBuf -#include "ipAddrToA.h" +#include "bsdSocketResource.h" casDGIO::~casDGIO() { diff --git a/src/cas/io/bsdSocket/casDGIntfIO.cc b/src/cas/io/bsdSocket/casDGIntfIO.cc index 96eb11860..f04107eb9 100644 --- a/src/cas/io/bsdSocket/casDGIntfIO.cc +++ b/src/cas/io/bsdSocket/casDGIntfIO.cc @@ -35,7 +35,7 @@ // #include "server.h" -#include "ipAddrToA.h" +#include "bsdSocketResource.h" #include "addrList.h" // @@ -65,6 +65,10 @@ caStatus casDGIntfIO::init(const caNetAddr &addr, unsigned connectWithThisPortIn unsigned short beaconPort; ELLLIST BCastAddrList; + if (!bsdSockAttach()) { + return S_cas_internal; + } + if (pAltOutIn) { this->pAltOutIO = pAltOutIn; } @@ -220,11 +224,13 @@ caStatus casDGIntfIO::init(const caNetAddr &addr, unsigned connectWithThisPortIn // casDGIntfIO::~casDGIntfIO() { - if(this->sock!=INVALID_SOCKET){ - socket_close(this->sock); - } + if(this->sock!=INVALID_SOCKET){ + socket_close(this->sock); + } ellFree(&this->beaconAddrList); + + bsdSockRelease(); } // diff --git a/src/cas/io/bsdSocket/casIntfIO.cc b/src/cas/io/bsdSocket/casIntfIO.cc index e58fa9d7a..12af91dab 100644 --- a/src/cas/io/bsdSocket/casIntfIO.cc +++ b/src/cas/io/bsdSocket/casIntfIO.cc @@ -6,6 +6,9 @@ // // // $Log$ +// Revision 1.5 1998/05/29 20:08:21 jhill +// use new sock ioctl() typedef +// // Revision 1.4 1998/02/05 23:11:16 jhill // use osiSock macros // @@ -21,6 +24,7 @@ // #include "server.h" +#include "bsdSocketResource.h" // // 5 appears to be a TCP/IP built in maximum @@ -49,11 +53,16 @@ caStatus casIntfIO::init(const caNetAddr &addrIn, casDGClient &dgClientIn, caStatus stat; int addrSize; + if (!bsdSockAttach()) { + return S_cas_internal; + } + /* * Setup the server socket */ this->sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (this->sock==INVALID_SOCKET) { + printf("No socket error was %s\n", SOCKERRSTR); return S_cas_noFD; } @@ -184,6 +193,8 @@ casIntfIO::~casIntfIO() if (this->pBCastUDP) { delete this->pBCastUDP; } + + bsdSockRelease(); } // diff --git a/src/cas/io/bsdSocket/casStreamIO.cc b/src/cas/io/bsdSocket/casStreamIO.cc index d9efd56bb..2e7ba0588 100644 --- a/src/cas/io/bsdSocket/casStreamIO.cc +++ b/src/cas/io/bsdSocket/casStreamIO.cc @@ -5,6 +5,9 @@ // // // $Log$ +// Revision 1.15 1998/05/29 20:08:21 jhill +// use new sock ioctl() typedef +// // Revision 1.14 1998/02/05 23:12:01 jhill // use osiSock macros // @@ -53,7 +56,7 @@ // #include "server.h" -#include "ipAddrToA.h" +#include "bsdSocketResource.h" // @@ -73,71 +76,71 @@ casStreamIO::casStreamIO(caServerI &cas, const ioArgsToNewStreamIO &args) : // caStatus casStreamIO::init() { - int yes = TRUE; + int yes = TRUE; int status; int i; - /* - * see TCP(4P) this seems to make unsollicited single events much - * faster. I take care of queue up as load increases. - */ - status = setsockopt( - this->sock, - IPPROTO_TCP, - TCP_NODELAY, - (char *)&yes, - sizeof(yes)); - if (status<0) { + /* + * see TCP(4P) this seems to make unsollicited single events much + * faster. I take care of queue up as load increases. + */ + status = setsockopt( + this->sock, + IPPROTO_TCP, + TCP_NODELAY, + (char *)&yes, + sizeof(yes)); + if (status<0) { ca_printf( "CAS: %s TCP_NODELAY option set failed %s\n", __FILE__, SOCKERRSTR); return S_cas_internal; - } + } - /* - * turn on KEEPALIVE so if the client crashes - * this task will find out and exit - */ - status = setsockopt( - sock, - SOL_SOCKET, - SO_KEEPALIVE, - (char *)&yes, - sizeof(yes)); - if (status<0) { + /* + * turn on KEEPALIVE so if the client crashes + * this task will find out and exit + */ + status = setsockopt( + sock, + SOL_SOCKET, + SO_KEEPALIVE, + (char *)&yes, + sizeof(yes)); + if (status<0) { ca_printf( "CAS: %s SO_KEEPALIVE option set failed %s\n", __FILE__, SOCKERRSTR); return S_cas_internal; - } + } - /* - * set TCP buffer sizes to be synergistic - * with CA internal buffering - */ - i = MAX_MSG_SIZE; - status = setsockopt( - sock, - SOL_SOCKET, - SO_SNDBUF, - (char *)&i, - sizeof(i)); - if(status < 0){ - ca_printf("CAS: SO_SNDBUF set failed\n"); - return S_cas_internal; - } - i = MAX_MSG_SIZE; - status = setsockopt( - sock, - SOL_SOCKET, - SO_RCVBUF, - (char *)&i, - sizeof(i)); - if(status < 0){ - ca_printf("CAS: SO_RCVBUF set failed\n"); - return S_cas_internal; - } + /* + * set TCP buffer sizes to be synergistic + * with CA internal buffering + */ + i = MAX_MSG_SIZE; + status = setsockopt( + sock, + SOL_SOCKET, + SO_SNDBUF, + (char *)&i, + sizeof(i)); + if(status < 0){ + ca_printf("CAS: SO_SNDBUF set failed\n"); + return S_cas_internal; + } + i = MAX_MSG_SIZE; + status = setsockopt( + sock, + SOL_SOCKET, + SO_RCVBUF, + (char *)&i, + sizeof(i)); + if(status < 0){ + ca_printf("CAS: SO_RCVBUF set failed\n"); + return S_cas_internal; + } this->sockState = casOnLine;