socket_set_option() doesn't work in VPS

Avatar
  • Answered
well, let's make it simple.
my script manages connections' tcp sockets "customers (which are electronic devices)
to receive the data I use: socket_read ()
armo all taste in my local XAMPP server and going great.
I get on my vps in Inmotion, (after opening ports, etc etc) and also works well. (Celebrations)

It is not often, but it happens, sometimes one of the devices, and starts sending data halfway, say "turns off".
Blessed "\ n" will never reach the server to indicate that the transmission completed thus will remain hung hearing this, bad bad bad.

After studying the subject, I found that: socket_set_option ($ sock, SOL_SOCKET, SO_RCVTIMEO, array ( "sec" => 3, "usec" => 0));

With this simple line a timeout of 3 seconds on the socket when reading is generated. If the "\ n" does not arrive in less than 3 seconds, adios ... the process is over, and we move on to something else.

I try this on my localhost xampp and GENIAL .... IT WORKS!
I thought it would be a cinch, since the same script and worked on my VPS only lacked this line so that it will not crash due to the lack of a "\ n".

Add the line and nothing :(

I try setear other options socket_set_option () and nothing without effect,
Doing a deep debug any kind of warning or error does not occur.

I tried to upgrade and downgrade versions of php in vps, and nothing.
I played with everything about timeouts in php.ini and nothing

something ... i do not know what, disables the ability of the system to recognize socket_set_option ()
Even though if I enter my WHM and if I enter "PHP version" and then see the details. socket_set_option () is listed as admitted.

I would appreciate any assistance. Sorry for the length of my message.
Paul. From Cordoba Argentina.
Avatar
Scott
Hello,

Thank you for your question about the set_socket_option function in your phplist script. That function has been included in PHP since around 4.3 and is currently still in the new version 7. Our servers do not disable core php functions, however you can do so via the php.ini file. You can check that from within your php by using the if_exists function. I tested it on my server and it exists and works. Unless it is disabled in the php.ini file, it should exist.

Once you can confirm it exists, then you will simply need to look at the code for why it is not working for you.

Kindest Regards,
Scott M