summaryrefslogtreecommitdiff
path: root/src/network/core/tcp_connect.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-02 23:59:43 +0000
committerrubidium <rubidium@openttd.org>2009-04-02 23:59:43 +0000
commitc7b6469dabe5018775d075bee0a5293175024b42 (patch)
tree343b43841f480cbd2ab50df10adc949dbd3b954e /src/network/core/tcp_connect.cpp
parent521bf687eef36e7c06d09ee610134eb21fed69a9 (diff)
downloadopenttd-c7b6469dabe5018775d075bee0a5293175024b42.tar.xz
(svn r15920) -Codechange: make the (TCP) connecting less AF dependent.
Diffstat (limited to 'src/network/core/tcp_connect.cpp')
-rw-r--r--src/network/core/tcp_connect.cpp21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index a994fc6d2..2e292b5d0 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -31,27 +31,12 @@ TCPConnecter::TCPConnecter(const NetworkAddress &address) :
void TCPConnecter::Connect()
{
- DEBUG(net, 1, "Connecting to %s %d", address.GetHostname(), address.GetPort());
-
- this->sock = socket(AF_INET, SOCK_STREAM, 0);
+ this->sock = this->address.Connect();
if (this->sock == INVALID_SOCKET) {
this->aborted = true;
- return;
+ } else {
+ this->connected = true;
}
-
- if (!SetNoDelay(this->sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed");
-
- /* We failed to connect for which reason what so ever */
- if (connect(this->sock, (struct sockaddr*)this->address.GetAddress(), sizeof(*this->address.GetAddress())) != 0) {
- closesocket(this->sock);
- this->sock = INVALID_SOCKET;
- this->aborted = true;
- return;
- }
-
- if (!SetNonBlocking(this->sock)) DEBUG(net, 0, "Setting non-blocking mode failed");
-
- this->connected = true;
}