Go to Post You worry about your team. Let other people worry about their own teams. - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-08-2016, 16:18
nickbrickmaster's Avatar
nickbrickmaster nickbrickmaster is offline
Not Allowed Near Power Tools
AKA: Nick Schatz
FRC #3184 (Blaze Robotics)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 159
nickbrickmaster is an unknown quantity at this point
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 socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 5800))  # Bind to empty IP so it can use anything
s.connect(("192.168.1.3", 5800))  # 192.168.1.3 is the IP of my server
s.send(b"hello")
s.close()
Server
Code:
import socket

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('', 5800))  # Again, bind to any address, but this specific port
# become a server socket
serversocket.listen(1)

(client, addr) = serversocket.accept()
print("Recieved connection from {}".format(addr))
while True:
    data = client.recv(1024)
    if len(data) == 0:  # According to the spec, empty recieve means that the socket is closing
        break
    print("recv {}".format(data))
client.close()
According to Wireshark, this code only communicates on port 5800.
__________________
I have approximate knowledge of many things.

FRC 3184: 2014-, FTC 10648: 2015-
Reply With Quote
  #2   Spotlight this post!  
Unread 06-08-2016, 17:56
Technologyman00's Avatar
Technologyman00 Technologyman00 is offline
Registered User
AKA: Collin
FRC #1792 (Round Table Robotics)
Team Role: Mechanical
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Oak Creek WI
Posts: 23
Technologyman00 is an unknown quantity at this point
Re: Python Socket Between Devices

Thank you So Much for All of your help everything works great now!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi