From 549f90727d321cd6cf8850e8b510beba36925a82 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 21 Mar 2008 19:55:36 +0000 Subject: minor updates --- src/core/netclient.cc | 8 ++++---- src/core/netserver.cc | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/netclient.cc b/src/core/netclient.cc index 32e0f4b..dba6e2b 100644 --- a/src/core/netclient.cc +++ b/src/core/netclient.cc @@ -22,7 +22,7 @@ NetClient::NetClient(std::string host, int port) : con_print << host << ":" << port << " connects." << std::endl; // Get a socket file descriptor - client_fd = socket(PF_INET, SOCK_DGRAM, 0); + client_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (client_fd == -1) { con_warn << "Network client socket() failed!" << std::endl; abort(); @@ -45,7 +45,7 @@ NetClient::NetClient(std::string host, int port) : std::ostringstream osstream; client_player.player_id = client_fd; - sendq.erase(); + sendq.clear(); messageblock.clear(); client_error = false; @@ -105,14 +105,14 @@ void NetClient::receive(char *data) // TODO detect "begin binary block" message for zlib compression if (messageblock.size() > 0 ) { recvq.push_back(messageblock); - messageblock.erase(); + messageblock.clear(); } } else { if (messageblock.size() < FRAMESIZE) { messageblock.append(datablock.substr(0,1)); } else { con_warn << "Incoming message exceeds " << FRAMESIZE << " bytes!\n"; - messageblock.erase(); + messageblock.clear(); } } datablock.erase(0,1); diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 16f042e..9f2fea6 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -37,7 +37,7 @@ NetServer::NetServer(std::string const host, unsigned int const port) netserver_error = true; // initialize socket - netserver_fd = ::socket(PF_INET, SOCK_DGRAM, 0); + netserver_fd = ::socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (netserver_fd == -1) { con_error << "Network can't create socket!" << std::endl; //perror("socket"); @@ -238,6 +238,7 @@ NetClient * NetServer::client_connect(std::string const host, int const port) netmsg.str(""); netmsg << "msg info Receiving data from remote server...\n"; client->send(netmsg.str()); + transmit(); // send entities std::map::iterator it; -- cgit v1.2.3