Accept TCP socket in Python. I feel like I am missing something obvious

Hi, I am working on a serial to ethernet server with 2 Raspberry Pis to allow data to flow both ways. Here is the setup:

serial device <–(serial to USB converter)–> Pi A <–(ethernet)–> Pi B <–(serial to USB converter)–> computer

I can send data from Pi to Pi over ethernet and print serial data on Pi B from computer so I know my connections are good. I am trying to use something like tcp_serial_redirect or rfc2217_server to allow the data to be redirected from serial to ethernet and back.

I am very inexperienced with networking and am struggling to accept the connection on the port. Neither program seems to get past:

client_socket, addr = srv.accept()

They don’t have an error or quit, just wait. It seems like it is trying to open the port but not being accepted. So I tried to use a simple block from the socket documentation and either nothing happens or I get the message “cannot open socket.” If anyone has any insight I would really appreciate it, I know this is probably really easy for networking folks but I have spent an embarassing amount of time on it to no avail.

At the end of the day I am trying to have a version of one of the two programs linked above that I can have running on both machines. I assume they would have to be modified in some way to have a server/client relationship and that is where I am really struggling. Thanks very much in advance.

socket.accept() waits for an incoming client connection. This mean if it just waits there is no client trying to connect. The client must use socket.connect() while the server is accepting connections.