diff --git a/src/cas/io/bsdSocket/casIntfIO.cc b/src/cas/io/bsdSocket/casIntfIO.cc index 0195bee60..949db8fab 100644 --- a/src/cas/io/bsdSocket/casIntfIO.cc +++ b/src/cas/io/bsdSocket/casIntfIO.cc @@ -6,6 +6,9 @@ // // // $Log$ +// Revision 1.3 1997/06/13 09:16:15 jhill +// connect proto changes +// // Revision 1.2 1997/04/10 19:40:33 jhill // API changes // @@ -38,52 +41,50 @@ casIntfIO::casIntfIO() : caStatus casIntfIO::init(const caNetAddr &addrIn, casDGClient &dgClientIn, int autoBeaconAddr, int addConfigBeaconAddr) { - int yes = TRUE; - int status; - caStatus stat; - int addrSize; + int yes = TRUE; + int status; + caStatus stat; + int addrSize; - /* - * Setup the server socket - */ - this->sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (this->sock==INVALID_SOCKET) { - return S_cas_noFD; - } + /* + * Setup the server socket + */ + this->sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (this->sock==INVALID_SOCKET) { + return S_cas_noFD; + } - /* - * release the port in case we exit early - */ - status = setsockopt ( - this->sock, - SOL_SOCKET, - SO_REUSEADDR, - (char *) &yes, - sizeof (yes)); - if (status<0) { - ca_printf("CAS: server set SO_REUSEADDR failed?\n", - strerror(SOCKERRNO)); + /* + * release the port in case we exit early + */ + status = setsockopt ( + this->sock, + SOL_SOCKET, + SO_REUSEADDR, + (char *) &yes, + sizeof (yes)); + if (status<0) { + ca_printf("CAS: server set SO_REUSEADDR failed? %s\n", + SOCKERRSTR); return S_cas_internal; - } + } this->addr = addrIn.getSockIP(); - status = bind( - this->sock, - (sockaddr *) &this->addr, - sizeof(this->addr)); - if (status<0) { - if (SOCKERRNO == EADDRINUSE) { + status = bind(this->sock,(sockaddr *) &this->addr, + sizeof(this->addr)); + if (status<0) { + if (SOCKERRNO == SOCK_EADDRINUSE) { // // force assignement of a default port // (so the getsockname() call below will // work correctly) // - - this->addr.sin_port = ntohs (0); + + this->addr.sin_port = ntohs (0); status = bind( - this->sock, - (sockaddr *)&this->addr, - sizeof(this->addr)); + this->sock, + (sockaddr *)&this->addr, + sizeof(this->addr)); } if (status<0) { errPrintf(S_cas_bindFail, @@ -91,16 +92,17 @@ caStatus casIntfIO::init(const caNetAddr &addrIn, casDGClient &dgClientIn, "- bind TCP IP addr=%s port=%u failed because %s", inet_ntoa(this->addr.sin_addr), ntohs(this->addr.sin_port), - strerror(SOCKERRNO)); + SOCKERRSTR); return S_cas_bindFail; } - } + } addrSize = sizeof(this->addr); status = getsockname(this->sock, (struct sockaddr *)&this->addr, &addrSize); if (status) { - ca_printf("CAS: getsockname() error %s\n", strerror(SOCKERRNO)); + ca_printf("CAS: getsockname() error %s\n", + SOCKERRSTR); return S_cas_internal; } @@ -108,13 +110,13 @@ caStatus casIntfIO::init(const caNetAddr &addrIn, casDGClient &dgClientIn, // be sure of this now so that we can fetch the IP // address and port number later // - assert (this->addr.sin_family == AF_INET); + assert (this->addr.sin_family == AF_INET); - status = listen(this->sock, caServerConnectPendQueueSize); - if(status < 0) { - ca_printf("CAS: listen() error %s\n", strerror(SOCKERRNO)); - return S_cas_internal; - } + status = listen(this->sock, caServerConnectPendQueueSize); + if(status < 0) { + ca_printf("CAS: listen() error %s\n", SOCKERRSTR); + return S_cas_internal; + } // // set up a DG socket bound to the specified interface @@ -194,11 +196,11 @@ casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const length = sizeof(newAddr); newSock = accept(this->sock, &newAddr, &length); if (newSock==INVALID_SOCKET) { - if (SOCKERRNO!=EWOULDBLOCK) { + if (SOCKERRNO!=SOCK_EWOULDBLOCK) { ca_printf( "CAS: %s accept error %s\n", __FILE__, - strerror(SOCKERRNO)); + SOCKERRSTR); } return NULL; } @@ -230,7 +232,7 @@ void casIntfIO::setNonBlocking() if (status<0) { ca_printf( "%s:CAS: server non blocking IO set fail because \"%s\"\n", - __FILE__, strerror(SOCKERRNO)); + __FILE__, SOCKERRSTR); } } diff --git a/src/cas/io/bsdSocket/casStreamIO.cc b/src/cas/io/bsdSocket/casStreamIO.cc index 8b756dcfe..857485bcd 100644 --- a/src/cas/io/bsdSocket/casStreamIO.cc +++ b/src/cas/io/bsdSocket/casStreamIO.cc @@ -5,6 +5,9 @@ // // // $Log$ +// Revision 1.13 1997/06/30 23:40:50 jhill +// use %p for pointers +// // Revision 1.12 1997/06/13 09:16:16 jhill // connect proto changes // @@ -84,7 +87,7 @@ caStatus casStreamIO::init() if (status<0) { ca_printf( "CAS: %s TCP_NODELAY option set failed %s\n", - __FILE__, strerror(SOCKERRNO)); + __FILE__, SOCKERRSTR); return S_cas_internal; } @@ -101,7 +104,7 @@ caStatus casStreamIO::init() if (status<0) { ca_printf( "CAS: %s SO_KEEPALIVE option set failed %s\n", - __FILE__, strerror(SOCKERRNO)); + __FILE__, SOCKERRSTR); return S_cas_internal; } @@ -179,7 +182,7 @@ xSendStatus casStreamIO::osdSend(const char *pInBuf, bufSizeT nBytesReq, else if (status<0) { int anerrno = SOCKERRNO; - if (anerrno != EWOULDBLOCK) { + if (anerrno != SOCK_EWOULDBLOCK) { this->sockState = casOffLine; } nBytesActual = 0u; @@ -214,20 +217,20 @@ xRecvStatus casStreamIO::osdRecv(char *pInBuf, bufSizeT nBytes, * normal conn lost conditions */ switch(SOCKERRNO){ - case EWOULDBLOCK: + case SOCK_EWOULDBLOCK: nBytesActual = 0u; return xRecvOK; - case ECONNABORTED: - case ECONNRESET: - case ETIMEDOUT: + case SOCK_ECONNABORTED: + case SOCK_ECONNRESET: + case SOCK_ETIMEDOUT: break; default: ipAddrToA(&this->addr, buf, sizeof(buf)); ca_printf( "CAS: client %s disconnected because \"%s\"\n", - buf, strerror(SOCKERRNO)); + buf, SOCKERRSTR); break; } this->sockState = casOffLine; @@ -272,7 +275,7 @@ void casStreamIO::xSetNonBlocking() } else { ca_printf("%s:CAS: TCP non blocking IO set fail because \"%s\"\n", - __FILE__, strerror(SOCKERRNO)); + __FILE__, SOCKERRSTR); this->sockState = casOffLine; } } @@ -302,16 +305,16 @@ bufSizeT casStreamIO::incommingBytesPresent() const * normal conn lost conditions */ switch(SOCKERRNO){ - case ECONNABORTED: - case ECONNRESET: - case ETIMEDOUT: + case SOCK_ECONNABORTED: + case SOCK_ECONNRESET: + case SOCK_ETIMEDOUT: break; default: ipAddrToA(&this->addr, buf, sizeof(buf)); ca_printf( "CAS: FIONREAD for %s failed because \"%s\"\n", - buf, strerror(SOCKERRNO)); + buf, SOCKERRSTR); } return 0u; }