Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 28, 2024, 07:27:29 19:27


Login with username, password and session length


Pages: [1]
Print
Author Topic: TCP / UDP socket programming for Raspberry PI  (Read 3776 times)
0 Members and 1 Guest are viewing this topic.
puta
Junior Member
**
 Muted
Offline Offline

Posts: 89

Thank You
-Given: 358
-Receive: 29


« on: May 13, 2017, 01:51:48 01:51 »


I am doing experiments for a project that need to develop a telnet server on the Raspberry pi, and to provide remote cli access (via telnet client) to read various status of the PI.

Could someone point me to a good document on the TCP / UDP socket programming for Raspberry PI.

Thanks heaps for help !
 
Logged
adamantium
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 17
-Receive: 7


« Reply #1 on: May 14, 2017, 03:36:49 15:36 »

Hi puta,

It really depends on what programming languages you're familiar with, after all, Raspberry Pi's are just running ARM linux. Do you want to provide a telnet like server, with custom commands to read some statuses? Or do you want to provide actual shell command line access?

If the former, the easiest would be to just use python or javascript.

For example, if you're familiar with javascript load nodejs on the pi, create a project and use an npm dependency 'telnet' (https://www.npmjs.com/package/telnet), which lets you create a server that implements the Telnet protocol.

You can then use a callback function to listen for commands that the client sends, and respond accordingly.
Logged
puta
Junior Member
**
 Muted
Offline Offline

Posts: 89

Thank You
-Given: 358
-Receive: 29


« Reply #2 on: May 15, 2017, 04:23:40 04:23 »


Thanks Adamantium, it is the former, using python or javascript or other.

What i need is to implement telnet server on a none-standard tcp port ( other than standard port tcp/23), and implement functions/procedures to service various statuses ( simple eg, status of a port, or a value read on a spi bus) so that remote client can enter specific commands to execute functions/procedures on the server and read statuses.   
Logged
adamantium
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 17
-Receive: 7


« Reply #3 on: May 15, 2017, 06:26:16 06:26 »

Yep, you can do all that with node running on the pi. Use the telnet package I linked above, you can specify a port for it to listen on.

For reading port status you can use https://www.npmjs.com/package/rpi-gpio
And for communicating with SPI devices, https://www.npmjs.com/package/spi

I haven't used the telnet package personally, but I have used the gpio and spi ones in the past on a pi 2.
Logged
UKFlyer
Newbie
*
Offline Offline

Posts: 25

Thank You
-Given: 40
-Receive: 17


« Reply #4 on: July 20, 2017, 11:20:25 11:20 »

The book "Raspberry Pi IOT in C" has a good chapter on socket programming. Unfortunately the relevant chapter is not on the website but I've found the book worth buying.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC