Reputation: 75
I would like to make a BT communication between a laptop with a dongle BT and a Raspberry. They are both connected on a PAN network so they have both one IP address.
For the communication, I use a TCP socket. On the server part, I can create my socket until the accept method. Then I go on my RPi 3 and I run my python script:
import socket
hote = "192.168.50.1"
port = 1000
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((hote, port))
print("Connection on {}".format(port))
socket.close()
But I always have this output after few minutes:
Traceback (most recent call last):
File "socketClient.py", line 7, in <module>
socket.connect((hote, port))
TimeoutError: [Errno 110] Connection timed out
I don't know why... Do you have an idea ? I've tried the command telnet addr_ip port
on my laptop and i success the connection with the server.
Upvotes: 1
Views: 3438
Reputation: 75
It was a firewall problem because he stopped the entrance connection.I realized there when I reversed the roles. I put the server code on RPI and client code on my laptop and it worked.
Upvotes: 3
Reputation: 901
First of all, did you bind the socket? Second, are you listening on that IP and port?
The normal approach creating socket connections is:
Server side:
Client side:
Some information about network-programming in python: here and here
Upvotes: 0