In linux, php is used for socket programming and a connection rejection error is reported. Please check that this post was last edited by lovegis0101 at 08:40:57.
I am new to Linux, php, and socket (haha ....), I found some information on the Internet and wrote two basic php scripts on the client and server. in Windows, the test can communicate with each other. Then, the client script is placed in Linux, but the following error is reported:
PHP Warning: socket_connect (): unable to connect [111]: Connection refused in/socketClient. php on line 12, 12 is to call the socket_connect method, the error here
The system environment is like this. I have installed a Linux virtual machine on a Windows host. the Windows system ip address is 192.168.0.2 and the Linux system ip address is 192.168.102. the Two System networks are connected through bridging, linux can connect to the network through Windows.
This problem has plagued me for several days. I have not found a solution for searching online. please help me to see it.
Attach the script code:
Server:
Client:
Reply to discussion (solution)
It's so fast. let's take a look. I'm in a hurry. this step cannot be implemented, so we can't proceed next.
Since Windows is acceptable, linux is not acceptable. check the environment problems first...
Okay, the problem is found. The ip address monitored by the server should not be 127.0.0.1, but the actual ip address, 192.168.0.2.
The error code 111 is reported because there is no server program or the server program is not started.
It is good to find the problem by yourself.
Since Windows is acceptable, linux is not acceptable. check the environment problems first...
Haha thanks for reminding me that I have encountered this problem today and solved it.