Merge pull request #63 from vibe-d/fix_connect_socket_callback
Call the callback on connectStream socket creation failure.
This commit is contained in:
commit
68b8f44957
|
@ -570,6 +570,7 @@ enum ConnectStatus {
|
||||||
refused,
|
refused,
|
||||||
timeout,
|
timeout,
|
||||||
bindFailure,
|
bindFailure,
|
||||||
|
socketCreateFailure,
|
||||||
unknownError
|
unknownError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,10 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
||||||
assert(on_connect !is null);
|
assert(on_connect !is null);
|
||||||
|
|
||||||
auto sockfd = createSocket(address.addressFamily, SOCK_STREAM);
|
auto sockfd = createSocket(address.addressFamily, SOCK_STREAM);
|
||||||
if (sockfd == -1) return StreamSocketFD.invalid;
|
if (sockfd == -1) {
|
||||||
|
on_connect(StreamSocketFD.invalid, ConnectStatus.socketCreateFailure);
|
||||||
|
return StreamSocketFD.invalid;
|
||||||
|
}
|
||||||
|
|
||||||
auto sock = cast(StreamSocketFD)sockfd;
|
auto sock = cast(StreamSocketFD)sockfd;
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,10 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
||||||
assert(m_tid == GetCurrentThreadId());
|
assert(m_tid == GetCurrentThreadId());
|
||||||
|
|
||||||
auto fd = WSASocketW(peer_address.addressFamily, SOCK_STREAM, IPPROTO_TCP, null, 0, WSA_FLAG_OVERLAPPED);
|
auto fd = WSASocketW(peer_address.addressFamily, SOCK_STREAM, IPPROTO_TCP, null, 0, WSA_FLAG_OVERLAPPED);
|
||||||
if (fd == INVALID_SOCKET)
|
if (fd == INVALID_SOCKET) {
|
||||||
|
on_connect(StreamSocketFD.invalid, ConnectStatus.socketCreateFailure);
|
||||||
return StreamSocketFD.invalid;
|
return StreamSocketFD.invalid;
|
||||||
|
}
|
||||||
|
|
||||||
void invalidateSocket() @nogc @trusted nothrow { closesocket(fd); fd = INVALID_SOCKET; }
|
void invalidateSocket() @nogc @trusted nothrow { closesocket(fd); fd = INVALID_SOCKET; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue