简体   繁体   中英

Can Websocket able to receive data from ajax?

I am trying to building a php and html5 websocket chat system where one end will be socket and other end will be ajax. Is it possible PHP's socket_recv() function receive data from ajax/mysql or from any other source(which is not send by "send" method or socket)?

** We want one end in ajax because still websocket is not supported by all browser specially IE.

Please help.

If you're not going to use WebSockets on the client end, you don't need them on the server side either. (Indeed, you can't use them unless both parties support them.) AJAX creates normal HTTP requests; you can handle them just like any other request in PHP.

Also, critically: the PHP socket_ functions are raw TCP/UDP sockets, not WebSockets. The WebSocket protocol is considerably more complicated than they support directly. PHP sockets can be used in the process of implementing WebSockets, but it's much better to use a library like Ratchet which has already done the heavy lifting for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM