Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 21, 2017, 02:58:19 02:58


Login with username, password and session length


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

Posts: 70

Thank You
-Given: 211
-Receive: 23


« on: May 13, 2017, 02:51:48 02: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: 7

Thank You
-Given: 13
-Receive: 2


« Reply #1 on: May 14, 2017, 04:36:49 16: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
**
Offline Offline

Posts: 70

Thank You
-Given: 211
-Receive: 23


« Reply #2 on: May 15, 2017, 05:23:40 05: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: 7

Thank You
-Given: 13
-Receive: 2


« Reply #3 on: May 15, 2017, 07:26:16 07: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
iot
Newbie
*
Offline Offline

Posts: 21

Thank You
-Given: 31
-Receive: 13


« Reply #4 on: July 20, 2017, 05:41:47 05:41 »

Consider to use "Twisted Python"... very nice for network programming.
Logged
UKFlyer
Inactive

Offline Offline

Posts: 6

Thank You
-Given: 1
-Receive: 2


« Reply #5 on: July 20, 2017, 12:20:25 12: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