Changeset 14:3caa1d3122db in xplcommon for src/xplcommon/posix/Connector.cc
- Timestamp:
- 12/29/12 10:03:12 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplcommon/posix/Connector.cc
r6 r14 34 34 #include "ClientSocket.h" 35 35 36 #include <cerrno>37 38 36 #include <poll.h> 39 37 #include <sys/socket.h> … … 53 51 const struct sockaddr* addr = getAddress(addrlen); 54 52 55 int result = ::connect(socket.fd, addr, addrlen); 56 if (result<0) { 57 if (errno==EINPROGRESS) { 58 connecting = true; 59 socket.events |= POLLOUT; 60 } else { 61 setErrorCode(errno); 62 } 53 if (socket.connect(addr, addrlen)) { 54 connected = true; 55 return true; 56 } else if (socket.failed()) { 57 return false; 63 58 } else { 64 connected = true; 59 connecting = true; 60 socket.events |= POLLOUT; 61 return false; 65 62 } 66 67 return result==0;68 63 } 69 64 … … 80 75 socklen_t len = sizeof(error); 81 76 if (getsockopt(socket.fd, SOL_SOCKET, SO_ERROR, &error, &len)<0) { 82 s etErrorCode(errno);77 socket.setErrorCodeFromErrno(); 83 78 } else { 84 79 if (error==0) { 85 80 connected = true; 86 81 } else { 87 s etErrorCode(error);82 socket.setErrorCode(error); 88 83 } 89 84 }
Note:
See TracChangeset
for help on using the changeset viewer.