Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/netclient.cc8
-rw-r--r--src/core/netserver.cc3
2 files changed, 6 insertions, 5 deletions
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<unsigned int, Entity *>::iterator it;