-1

I am trying to build a robot that captures images from the RPi camera that is in installed, and try to sent it over to my Mac to do the image recognition and sent the result back. The robot was controlled by the Raspberry Pi 3 Model B. I have tried to communicate through socket but the whenever the it tries to connect, it always says “Connection refused” Any suggestions on new ways to communicate the RPi and the Mac wirelessly?

This is the code for the Server:

import socket
server = socket.socket()
server.bind(('127.0.0.1', 8000)) 
server.listen(0)
connection = server.accept()[0].makefile('wb') 
print("success")

This is the code for the Client:

import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('127.0.0.1', 8000))
connection = client.makefile('rb')
print('connection sucessful')    

Remember: I am just trying to make sure that the connection between the Raspberry Pi and the Mac is successful.

1 Answers1

0

I just figure it out. I just noticed that before I even connect, I am already connected to the RPi using SSH. I was using this so I could edit the code of the RPi. So what I did is that I connected the RPi to a different device, and then run the server code on the Mac, and the client on the RPi. It was a success.

Sorry if you were having a hard time answering my question. After all, it was just a mistake noticing the SSH connection.