A little daemon (?) to monitor ports? - a small project to get started with Rust


I bought a licence for a (Java) chatbot some years ago and wrote a little Ruby script (see below) to listen to the appropriate port and process incoming chats. Now I want to create something a little more sophisticated that could would replace the functionality of the Ruby script but also be expanded into something that could deal with other inputs and outputs.

Since I want to start learning Rust, I wanted to get some feedback about how to proceed with my Chatbot to Avatar project that involves writing this "Executive Function System" in Rust - which I think should be trivial (? - at least to begin with?) - here is a sketch from a while ago which I think is still valid but so much has happened with AI and Natural Language chat bots etc that more could be added to this diag:


If I write this ExFuSys thing in Rust it would need to (in the first case):

  • be started as a daemon?
  • have a module that listens on the chatbot port and processes chats

I invisage the ExFuSys core could be doing a lot more in the future (much like the frontal lobe of a human brain) so it seems like a good idea to write this in Rust?

Feedback appreciated!



require 'socket'
require 'json'

lhost = Socket.gethostname
session = "SESSION_"
session = session + `echo $LOGNAME`.chomp
session = session + "_#{lhost}"
session = session + ".pricom.com.au"

session_init = "@" + session

host = ARGV.shift

if host == nil
	host = "localhost"

port = ARGV.shift

if port == nil
	port = 9192

dfname = nil

if dfname == nil
  dfname = 'Unknown Unknown'

dname = dfname.split[0]

while true
  print "> "
  input = gets.chomp
#  puts input

  if (input == "quit") then

  xmit = {
    :commands => {
    :users_name => "Philip",
    :users_fullname => "Philip Rhoades",
    :name => "Phil"
    :topic_slug => "phirhodev",
    :session_id => session_init,
    :message => input

  # Send it and get the client response
  s = TCPSocket.open( host, port )
  s.puts xmit.to_json

  while true
    response = s.gets.chomp

    if response == "@@END_OF_REPLY"
  puts response


Writing one's first significant software in Rust is never trivial. :confounded: Once you grok unique (&mut) vs shared (&) borrowing and that all data must be allocated/owned by something for its entire lifetime, it becomes somewhat easier, but for your first year or so it probably won't be that easy, and certainly not "trivial".

1 Like

Just to expand on @TomP answer (which sounded a bit gloomy :stuck_out_tongue: ) with a personal note.
One of the best things about Rust compared to other languages is that once the software runs it has much much less runtime errors.
While reading a lot of threads on this forum I found many other people also found this to be true, allowing them to sleep well after deploying their newest implementation of whatever they worked on :smiley:

@TomP , @raidwas ,

Thanks for the feedback - I have made a start with a TCP server example and will post in a separate thread about a couple of issues . .


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.