1

So I got the connection timed out error (error 110)

This is the IP address I got from ipconfig /all: IP address in red circle

And this is the code I use for client (the RasPi): import socket

TCP_IP = '192.168.2.52'
TCP_PORT = 5005
BUFFER_SIZE = 1024 

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))  #this is where the error came in
s.send(message)
data = s.recv(BUFFER_SIZE)
s.close()

print("Received data: ", data)

This is the code I have for the host computer:

import socket

TCP_IP = ''
TCP_PORT = 5005
BUFFER_SIZE = 1024 

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)

conn, addr = s.accept()
print ('Connection address:', addr)
while 1:
    data = conn.recv(BUFFER_SIZE)
    if not data: break
    print ("received data:", data)
    conn.send(data)  # echo
conn.close()

Both of the devices are connected to the same network, but I have been tinkering around for the last couple of hours but still failed to get a connection between the 2.

Any idea? Seems like a pretty basic snippet of code. Thanks!

Anh Tran
  • 111
  • 3

1 Answers1

0

Since your server seems to be windows-based, you're likely being bitten by the firewall. Disable it, or make an exception for port 5005.

Alternatively, try running the server snipped on the RPi and the client snippet on the computer, and see how that goes.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147