Jump to content

php Chat MySQL Bad Practice


KnowSkill

Recommended Posts

You should use websocket for a chat, constant polling php is too much usage for the server.

 

http://socket.io/get-started/chat/

http://tutorialzine.com/2014/03/nodejs-private-webchat/

http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket

 

You can search for others, this is the basic idea.

Yes, pretty much any real-time chat system is going to use TCP sockets. With a TCP connection, a client connects to a server and the connection remains open, or, "persistent". Data is more-or-less only sent one way or the other when something happens, like when a chat message is sent. If you do not use a persistent connection, and instead rely on polling, then you have to request data at continuous intervals even if there is no data to give. In such a system the messages will not be in real time, either, and will only be received when the client asks for them.

 

Now, if there is not going to be a web component then there is no point using WebSockets. You're better off just using straight up TCP protocol if you don't need web chat. And I wouldn't use PHP either, it's not really good at that. Java or NodeJS would be better choices.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.