Commit 71a47f8f authored by verdelyi's avatar verdelyi
Browse files

Throw exception on TCP bind failure instead of exiting immediately.

This makes it possible to choose another port when trying to construct an rpcs on a random port.
parent 88194c2e
......@@ -298,8 +298,7 @@ tcpsconn::tcpsconn(chanmgr *m1, int port, int lossytest)
setsockopt(tcp_, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
if(bind(tcp_, (sockaddr *)&sin, sizeof(sin)) < 0){
perror("accept_loop tcp bind:");
assert(0);
throw PortBusyException(std::string("accept_loop tcp bind error: ") + std::string(strerror(errno)));
}
if(listen(tcp_, 1000) < 0) {
......
......@@ -7,11 +7,16 @@
#include <netinet/in.h>
#include <map>
#include <stdexcept>
#include "pollmgr.h"
class connection;
class PortBusyException : public std::runtime_error {
using runtime_error::runtime_error;
};
class chanmgr {
public:
virtual bool got_pdu(connection *c, char *b, int sz) = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment