We help IT Professionals succeed at work.

how making Chat application with delphi using sockets?

Last Modified: 2018-12-12
Using  serversocket and clientsocket components I could build a chat program with delphi xe 10 seattled.
When ClientSocket is connected to a localHost with host='' and  port=21 and the ServerSocket activated with Port=21 then every thing is going well and the communication was established.
However I would like to transfer my ServerApplication(with ServerSocket) to a real server(not a local one). I have two options:
1. Simply using my web (hosted in a server which is not mine)
2. Purchase a server for my own.
In both cases I don't know how to do it...
Please help!
Watch Question

KimputerIT Manager

First you have to find out what you wish to use for the Web development. As you cannot just use the EXE server and client app you wrote. You can use parts of the code for sure, just not the whole idea of server/client app.
Check what you find it the most easy way here: https://www.embarcadero.com/solutions/web-2-0-development
(I recommend totally stopping with Delphi, and start with MS .Net, as you can see that's a partial solution mentioned there, but you'll be adding another layer of complexity which is totally unnecessary if you do it directly in .Net)
Adjust your code to run the client (server app can stay the same). After it works, you will need a server you have FULL control over. A web hosting server WILL NOT do. Most VMs you can have as a paid subscription are sometimes also not enough under your own control (for instance, shared IP nr). You'll be better off buying a new server.
Now test is locally, see if the web client app will talk to your server app. After that's done, open ports 80 or 443, and you can use your chat app from everywhere.


Thank you for your reply...
This small chat program I am working on is a very small part of a huge Desktop Application no way to make any migration now!
I expected a more specific answer to my question. I believe the one who can help me should know well sockets components in delphi.
My small chat program already runs very well with my local server(localhost), and I am planning to get a server with full control. I simply don't understand where my main serversocket program will live to operate....
KimputerIT Manager

If you want a more specific answer, you have to give more specific details. And by that I mean, the more specific details of the current situation and just as specific what you exactly want.
For now, the answer for "I simply don't understand where my main serversocket program will live to operate...." would probably, just the same as it is now. It's running on your PC, so after you get a new server, just run it on the server.
If the Desktop app runs on the server as well, nothing changes.
If the Desktop stays on the PC, then the IP should point to the server.


Very Interesting !!

"If the Desktop app runs on the server as well, nothing changes"
You mean that a Desktop application can run on a server? Even if this server is not a Windows Server as I was told?
That would do the job for me!

"If the Desktop stays on the PC, then the IP should point to the server"
But how then the server application will be accessed by many users???
IT Manager
This one is on us!
(Get your first solution completely free - no credit card required)


Thank you a lot. I think you told me what I need to know...
Sinisa VukSoftware architect
Top Expert 2012

I can give you more directions...
Although, it is possible to implement p2p chat in Delphi, I suggest to use simple my sql database  hosted somewhere.
If you don't need something "fancy" - create one table with active clients, and one for message text (not yet delivered).
So, client connect o that db, use some login stuff, put yourself in first table. Then look who is connected in first table (excluding you),
send message - just insert record into second table where key is client id. All connected client reads form time to time from second table if there is something for them.....

Simple push-pull method.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.