Recent

Author Topic: TCPChat - A simple chat server in freepascal  (Read 1863 times)

el3ctrolyte

  • New Member
  • *
  • Posts: 27
TCPChat - A simple chat server in freepascal
« on: May 02, 2021, 12:11:15 pm »
https://github.com/el3ctr0lyte/TCPChat

It uses just synapse and the basic freepascal components, so lazarus isn't really needed, making the dependancies less.

I recently wrote a program that is just a simple multi threaded, multi client server that receives messages from clients and relays them to all other clients(including the client who originally sent the message). Long ago when i was starting with lazarus and synapse (and programming in general) i was struggling to find an example of how to write just this basic kind of program. Now that i am wiser i decided to write it myself and post it online.

For now it works on most platforms(only tested in linux) but only on linux will it detect disconnections. So basically it is only practical on linux.

It is just 142 lines long, so it is great for beginners to look around and learn from. :D
Maybe someone here can add some things to it, like comments. I have a sort TODO list with things in the README file on github that i would like to check off. Maybe someone here can help with that.


I have decided that i want to change direction with this project. It is now just a simple chat server with more advanced features than originally intended. I still plan on making a seperate github repo with a tutorial on how to make a simple multi client and multi threaded chat server.
« Last Edit: May 07, 2021, 09:30:23 am by el3ctrolyte »

lucamar

  • Hero Member
  • *****
  • Posts: 4022
It's a nice example, thanks.

Only ... well, I don't want to demean your work and effort and it's more of a general observation but ...

It would be nice if example authors added a small write-up explaining how they went about to write them and why, what pitfalls and shortcomings they found and how they overcame them, etc.

Kind of, say, a small "tutorial" about the program and the programming process; it would make the examples much more useful.

IMHO, of course :-[
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

el3ctrolyte

  • New Member
  • *
  • Posts: 27
Thats a fantastic idea! I think that would be much more useful than having people manually read through the code. I am going to do this :D Thanks!

el3ctrolyte

  • New Member
  • *
  • Posts: 27
Where would be an appropriate place to post such a write up? I plan on writing it this weekend but i have no idea where to put on other than on github.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 651
    • My github
Hi, thanks for sharing.

Where would be an appropriate place to post such a write up? I plan on writing it this weekend but i have no idea where to put on other than on github.

I think one place can be the github, other place can we the wiki of lazarus.

/BlueIcaro

lucamar

  • Hero Member
  • *****
  • Posts: 4022
Where would be an appropriate place to post such a write up?

IMHO, the best is to place it along with the code, which is in your case is github. Then, if there is a wiki page where a link to it would be useful, add one to it.

This way, those who know there is such an example (be e.g. reading this thread) can get it and the write-up all in one go, and those who don't but go to the wiki looking for info get to know it's there and pass to the first cathegory ;)
« Last Edit: May 04, 2021, 05:11:31 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018