controller: move creation of listening connection to constructor
Doing this synchronously results in better error messages.
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index d63519d..a07433b 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -152,6 +152,16 @@
self.buffered_input = ""
+ # Create listen socket
+ if self.passive:
+ self.logger.info("Create/listen at " + self.host + ":" +
+ str(self.port))
+ self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.listen_socket.setsockopt(socket.SOL_SOCKET,
+ socket.SO_REUSEADDR, 1)
+ self.listen_socket.bind((self.host, self.port))
+ self.listen_socket.listen(LISTEN_QUEUE_SIZE)
+
def filter_packet(self, rawmsg, hdr):
"""
Check if packet should be filtered
@@ -383,21 +393,7 @@
connection for now.
"""
- self.dbg_state = "starting"
-
- # Create listen socket
- if self.passive:
- self.logger.info("Create/listen at " + self.host + ":" +
- str(self.port))
- self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.listen_socket.setsockopt(socket.SOL_SOCKET,
- socket.SO_REUSEADDR, 1)
- self.listen_socket.bind((self.host, self.port))
- self.dbg_state = "listening"
- self.listen_socket.listen(LISTEN_QUEUE_SIZE)
-
- self.logger.info("Listening for switch connection")
- self.dbg_state = "running"
+ self.dbg_state = "running"
while self.active:
try: