1

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.

asked Apr 11, 2017 at 12:40

2 Answers 2

3

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.

answered Apr 11, 2017 at 13:30
Sign up to request clarification or add additional context in comments.

2 Comments

Tag your answer as a checked so others Canon test your solution im the future :)
Okey, then just remember about it :)
0

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:

  1. Create a socket
  2. Bind the socket to a specyfic interface and port
  3. Let the socket listen.
  4. in a loop, try to accept connections to the socket
  5. handle the connection

Client side:

  1. Create a client_socket
  2. Try to connect to the server socket.

Some information about network-programming in python: here and here

answered Apr 11, 2017 at 12:47

1 Comment

I read a lot of website on this subject.. So yeah all is done.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.