#!/usr/bin/python3
import socket
import threading
READER1_ADDR = ("127.0.0.1", 23008)
READER2_ADDR = ("127.0.0.1", 23009)
class wait_conn(threading.Thread):
def __init__(self, addr, name):
super(wait_conn,self).__init__()
self.name = name
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.sock.bind(addr)
self.sock.listen(3)
def run(self):
s, a = self.sock.accept()
print(self.name, ": Incomming connection from: ", s.getpeername())
s.close()
self.sock.close()
t1 = wait_conn(READER1_ADDR, "r1")
t1.start()
t2 = wait_conn(READER2_ADDR, "r2")
t2.start()
w1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
w1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
w1.bind(READER1_ADDR)
w1.connect(READER2_ADDR)
w1.close()
t1.join(1.0)
t2.join(1.0)
Obviously the difference is that kamailio does bind() and listen() on the socket (ip:port) first -- maybe that should have said to be clear about what case we talk here. So try with socket(), bind(), listen() and then connect().
Once there is listen() on a socket, read events for it mean accept() should be done. The kernel won't create an outgoing connection from a listen socket, but use ephemeral ports.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr- dev