Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment