javascript - PHP socket receive many data at same time -



javascript - PHP socket receive many data at same time -

i'm using php , websocket (javascript) communicate between client , server. process is: - server start socket, client connects to. - when server have new data, notifies clients. - client feedback received notification, server receives info , not sent info again. if client not respond after 10 seconds, server sent again.

case server sent client server many message 1 time time, client reply server server can not read data. or when many clients reply @ same time, server neither can not read data.

sever using function 'socket_recv' receive info client. problem how message in server.

detail code:

// create socket , start hear $socket = socket_create(af_inet, sock_stream, sol_tcp); socket_set_option($socket, sol_socket, so_reuseaddr, 1); socket_bind($socket, 0, 1155); socket_listen($socket); while (true) { // check new info , sent clients .......... .......... // end of test info , sent // check if there new info client $changed = $clients; socket_select($changed, $ null, $ null, 0, 10); // run through client foreach ($changed $changed_socket) { // read info sent client while (socket_recv($changed_socket, $buf, 1024, 0)> = 1) { // utilize of client info check , remove message reply of client } } sleep (1); }

javascript php sockets

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -