how making Chat application with delphi using sockets?

bish wakim
bish wakim used Ask the Experts™
on
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='127.0.0.1' 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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
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.

Author

Commented:
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....

Commented:
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.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
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???
Commented:
Obviously, it should be a Windows Server (since you're using Delphi). In most small businesses though, a "normal" Windows OS is used (to reduce costs).
Since you are buying the server, even if it's not a Windows Server, there are still enough possibilities to make it so.

If many users need to access the chat app, then you have to deploy just as many clients.

These are all items that should have been thought about BEFORE writing even one single line of code. You need a strong design basis before building something. If it's weak, and something changes, you'll have to start coding from scratch.

Anyway, don't act so "surprised" if my answers aren't what you're looking for. You forgot, that you gave almost no details, so I'm guessing most things until you provide more details.

Author

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

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial