MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / connect

Method connect

source/network/ODSocketClient.cpp:28–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include <boost/filesystem.hpp>
27
28bool ODSocketClient::connect(const std::string& host, const int port, uint32_t timeout, const std::string& outputReplayFilename)
29{
30 mSource = ODSource::none;
31
32 // As we use selector, there is no need to set the socket as not-blocking
33 sf::Socket::Status status = mSockClient.connect(host, port, sf::milliseconds(timeout));
34 if (status != sf::Socket::Done)
35 {
36 OD_LOG_ERR("Could not connect to distant server status="
37 + Helper::toString(status));
38 mSockClient.disconnect();
39 return false;
40 }
41 mSockSelector.add(mSockClient);
42 OD_LOG_INF("Connected to server successfully");
43
44 mOutputReplayFilename = outputReplayFilename;
45
46 mReplayOutputStream.open(mOutputReplayFilename, std::ios::out | std::ios::binary);
47 mGameClock.restart();
48 mSource = ODSource::network;
49 return true;
50}
51
52bool ODSocketClient::replay(const std::string& filename)
53{

Callers

nothing calls this directly

Calls 2

toStringFunction · 0.70
disconnectMethod · 0.45

Tested by

no test coverage detected