]> git.tdb.fi Git - r2c2.git/blobdiff - source/network/server.cpp
Adapt to mspnet API changes
[r2c2.git] / source / network / server.cpp
index c9a56e39b243d7673d15c80259d4410658aabe8f..d4e2049472c94caf42da31f7ac2042ecc0246e8d 100644 (file)
@@ -1,4 +1,6 @@
+#include <msp/core/refptr.h>
 #include <msp/net/inet.h>
+#include <msp/net/resolve.h>
 #include "libr2c2/driver.h"
 #include "libr2c2/route.h"
 #include "libr2c2/train.h"
@@ -25,7 +27,8 @@ Server::Server(Layout &l):
        for(map<unsigned, Train *>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
                train_added(*i->second);
 
-       listen_sock.listen(Net::InetAddr(0, 8315), 4);
+       RefPtr<Net::SockAddr> addr = Net::resolve("*", "8315", Net::INET);
+       listen_sock.listen(*addr, 4);
        listen_sock.signal_data_available.connect(sigc::mem_fun(this, &Server::incoming_connection));
 }
 
@@ -210,7 +213,6 @@ void Server::Connection::handshake_done()
 
 void Server::Connection::end_of_file()
 {
-       socket->close();
        stale = true;
 }
 
@@ -230,7 +232,7 @@ void Server::Connection::receive(const TrainControlPacket &pkt)
                Train &train = server.layout.get_train(pkt.address);
                train.set_control(pkt.control, pkt.value);
        }
-       catch(const Exception &e)
+       catch(const exception &e)
        {
                error(e.what());
        }
@@ -245,7 +247,7 @@ void Server::Connection::receive(const TrainFunctionPacket &pkt)
                        if(((pkt.functions^train.get_functions())>>i)&1)
                                train.set_function(i, (pkt.functions>>i)&1);
        }
-       catch(const Exception &e)
+       catch(const exception &e)
        {
                error(e.what());
        }
@@ -264,7 +266,7 @@ void Server::Connection::receive(const TrainRoutePacket &pkt)
                        train.set_route(&route);
                }
        }
-       catch(const Exception &e)
+       catch(const exception &e)
        {
                error(e.what());
        }