![]() |
Python Socket Between Devices
I am currently working on controlling a RPI with a Socket Server and Client but when I do it on my PC using 127.0.0.1 but now it wont work on my home network. I know the IP address of the Devices I'm using but it never sees the other device.
PLZ HELP Server: Code:
#!/usr/bin/env pythonCode:
#!/usr/bin/env python |
Re: Python Socket Between Devices
Here's what I see:
On the client side, you should not bind() the socket to an IP. You just need to use connect() You do not want to keep connecting to find the IP of your server. You should give it a static IP address, or you can use the Pi mDNS name raspberrypi.local. Can you clarify your setup a little? I assume that your server is the Pi because it's controlling the LEDs, but what is your client device? A computer? Have you looked at https://docs.python.org/2/howto/sockets.html? This doc will explain basic socket usage. |
Re: Python Socket Between Devices
Thank you for all of your help! You have been the FIRST to respond on all of my recent projects posts.
Removing Bind() worked but how do I know they will connect over the FMS with only certain ports open? Thanks Again, Collin |
Re: Python Socket Between Devices
Happy to help.
Are you running the python client program on the driver station laptop? If not, then I don't think you need to worry. If so, checkout R60, which has been pretty consistent for the past few years. That will tell you what ports you can use for what. |
Re: Python Socket Between Devices
I am running it on the Driver Station and I know about R60 but the client picks a random port to respond on. How do I fix that?
Also I know all the IPs it could be but is there a way to know immediately what ip or use s.connect much faster? You are honestly Awesome. |
Re: Python Socket Between Devices
Quote:
Code:
ip addr showQuote:
If it's working now (despite taking a time to connect) you should be fine. |
Re: Python Socket Between Devices
I can figure out the IP no problem if I have direct access to it. But I was wondering if theirs an easy way to find it on the FMS. I know about 10.17.92.X but the X is the part I dont know. I currently have code to look through all of the possible ones and I assume that it will probably be in the lower numbers but currently it takes a long time to look through the IP addresses.
And then for the Port thing the Server is on port 5800 which is listed on R60 but the client will reply on something around 57869 which isnt open on the FMS will this be an issue? When I did s.bind it solved this issue but wont connect but now it will pick random port and connect that way. |
Re: Python Socket Between Devices
Like I said, give your Pi a static IP address, or just replace 10.TE.AM.XX with raspberrypi.local.
That will definitely be an issue. You're right, putting bind() back in the client will fix it. Here's my code that I tested this with. Uses python 3, so might be a little different than yours. Client Code:
import socketCode:
import socket |
Re: Python Socket Between Devices
Thank you So Much for All of your help everything works great now!
|
| All times are GMT -5. The time now is 10:02. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi