Writing using functions I can add it properly using the confirmation and it works as expected.
However my PHP-CLI client is not working properly. It seems like the client is trying to get the socket from the server (yes the server / client is on the same system).
They start connecting, but if I have to get the client just to receive the server's welcome message it just stalls. If I have written after adding the customer, the server sends everything, and the customer starts reading properly - but then the server socket_bread incorrect (i.e. an error), but the error message "operation successfully Completed "with.
This is my default algorithm:
Server
$ this-> _clientSock = socket_create (AF_INET, SOCK_STREAM), SOL_TCP); Socket_bind ($ this-> _clientSock, $ this-> _address, $ this- & gt; _port); // port 50000 socket_listen ($ this-> _clientSock, 5); $ This- & gt; _clientMsgSock = socket_accept ($ this- & gt; _clientSock); $ Msg = "Welcome"; Socket_write ($ this-> _clientMsgSock, $ msg, strlen ($ msg)); While {$ buffer = socket_read ($ this-> _clientMsgSock, $ this-> _readSize, PHP_NORMAL_READ)) $ INMsg = $ buffer; $ Msg = "You have sent '$ inMsg'; Socket_write ($ this-> _clientMsgSock, $ msg, strlen ($ msg));} while ($ msg! =" Skip ");
client $ this-> _serverSock = socket_create (AAUNETET, SOACAKRRM, SOOOLOCCP); Socket_connect ($ this-> _serverSock, $ This- & gt; _address, $ this- & gt; _port); Socket_write ($ this-> _serverSock, $ msg, strlen ($ msg)); // With this line, the server "socket_read" Otherwise the customer is hanging ($ buffer = socket_read ($ this-> _serverSock, $ this-> _readSize, PHP_NORMAL_READ)) $ inMBsg = $ buffer; Print is "Welcome Message $ INMsg";
I think you should at least socket_connect ()