+Socket::Socket(const string &host, unsigned short port)
+: sock(nullptr) {
+ IPaddress ip;
+ if (SDLNet_ResolveHost(&ip, host.c_str(), port) == -1) {
+ throw NetError("failed to resolve host " + host);
+ }
+ sock = SDLNet_TCP_Open(&ip);
+ if (!sock) {
+ throw NetError("failed to connect to " + host + ':' + to_string(port));
+ }
+}
+