Posts: 1
Joined: Wed Apr 05, 2017 4:20 pm

How to have pi respond to calls over ethernet

Wed Apr 05, 2017 4:27 pm


For a new project i would like to make an app, in this app you could select a pin and turn it on or off.
The app would then send a message to the pi over WiFi/internet and the pi will, when it is received, perform the corresponding action.
Now my question is how can i have the pi listen for the ethernet package and respond when it is received?
the program on the pi will probably be either C# or JAVA but if needed could also be python

thanks in advance

Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: How to have pi respond to calls over ethernet

Thu Apr 06, 2017 6:32 am

I have edited the thread title - currently this is not a 'HOW TO'...
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):

Posts: 63
Joined: Fri Feb 06, 2015 2:19 pm

Re: How to have pi respond to calls over ethernet

Sat Apr 08, 2017 6:47 am

I have actually done this to remotely "Press the on button" on another computer to turn it on by wiring up a relay to be controlled by a Pi via a GPIO pin. However you probably don't use RISCOS so the code is not very useful but the concept might be. I wrote, some time ago (1997 approx), a inetd equivalent and used this to listen on a UDP port waiting for a message over the net. The inetd then runs my program, one I wrote last year, to modify the state of a pin or pins according to the information in the UDP packet. That's the server end. The client end could go two ways. The first is you could send the UDP packet directly from the client, the second, by using a website, on another machine, from the client which in turn sends the UDP packet, I chose a server running Glassfish as I could write this bit in Java. If running Linux on the Pi then the inetd and Glassfish could run on the same Pi, but you would have to use a Pi 3 as the Glassfish is very resource hungry.

An alternative, you could write the server end in Java running on Glassfish or Tomcat and use the Pi4J library to communicate with the GPIO, this misses out the inetd part and all you have to do on your client is go to a web page.

There were reasons I went down the longer and convoluted route to fit in my situation, the alternative above may be better for you.

Return to “Advanced users”