I'm trying to read data from a TCP/IP port using python. You can see from the TCPView screenshot below that the data is flowing from the application successfully, but I'm getting nothing from the code below, (I get the first print output and then just a blinking cursor).
import socket
TCP_IP = "127.0.0.1"
TCP_PORT = 31003
BUFFER_SIZE = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((TCP_IP, TCP_PORT))
print("connected: ", s)
data = s.recv(BUFFER_SIZE)
s.close()
print("received data: ", data)
The line
print("connected: ", s)
this indicates that the data is outputting to the local port 60840, rather than the local port 61893 which is indicated by TCPView. Changing the script to listen to the local port named in TCPView has no effect.