| 201 | |
| 202 | |
| 203 | bool connect(Exception& ex, const SocketAddress& address,bool allowBroadcast) { |
| 204 | if (!_initialized && !init(ex, address.family())) |
| 205 | return false; |
| 206 | |
| 207 | ioctl(ex,FIONBIO, 1); // set non blocking mode before connect |
| 208 | |
| 209 | if (allowBroadcast && address.host().isAnyBroadcast()) |
| 210 | setOption(ex, SOL_SOCKET, SO_BROADCAST,1); // ex is warning here |
| 211 | |
| 212 | |
| 213 | #if defined(_WIN32) |
| 214 | managed(ex); // warning (call before connect to receive FD_CONNECT event for Windows) |
| 215 | #endif |
| 216 | |
| 217 | int rc = ::connect(_sockfd, address.addr(), address.size()); |
| 218 | |
| 219 | if (rc) { |
| 220 | int err = Net::LastError(); |
| 221 | if (err != NET_EINPROGRESS && err != NET_EWOULDBLOCK) { |
| 222 | Net::SetException(ex, err," (address=",address.toString(),", allowBroadcast=",allowBroadcast,")"); |
| 223 | return false; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | lock_guard<mutex> lock(_mutexAsync); |
| 228 | if(rc) |
| 229 | _connecting = true; |
| 230 | _connected = true; |
| 231 | |
| 232 | #if !defined(_WIN32) |
| 233 | managed(ex); // warning |
| 234 | #endif |
| 235 | return true; |
| 236 | } |
| 237 | |
| 238 | |
| 239 | bool bind(Exception& ex, const SocketAddress& address, bool reuseAddress) { |
nothing calls this directly
no test coverage detected