Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Socket comm with a Raspberry Pi Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 205
Posted: October 24 2020 at 15:04 | IP Logged Quote gg102

Hi Dave,


It's good to be back with everyone.

So far, I have been communicating with my Raspberry pi/s by dropping files on the pi/s and/or PH. This mostly works, but it is quite clumsy and not very reliable.
I am seeking a more reliable communication method. So I thought to try socket comms.



I have tried the following code to test:
PH
--------------------------------------------------

Formula:   ph_sendsocketdata('192.168.3.YYY', 8500,"Hello from PH_Server." )



Raspberry Pi :
--------------------------------------------------

#!/usr/bin/env python3

import socket

HOST = '192.168.3.XXX' # Address of PH
PORT = 8500   # Port of PH

client   =   socket.socket(soc ket.AF_INET, socket.SOCK_STREAM)
client.connect((HOST,PORT))

from_server = client.recv(4096)
client.send("I am Pi")
print ("From Server: " + from_server)
client.close()


What happens with this test setup is that PH times out, and the pi crashes on client.recv(...). I'm guessing that the socket never gets created, thus any attempt to comm will fail.

I'd like to hear your thoughts.
Thanks,

P.S. I think I fixed my private email address.
gg


Back to Top View gg102's Profile Search for other posts by gg102
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum