Yep.. I have the socket_hz method commented in my codings

.. I tried it and still block server and sometimes would require bigger timeout to see changes.
I inspired myself from sXe-injected:
PHP Code:
public client_putinserver(id)
{
connect_web(id); // The Auth process starts here! <<<<<<---------<<<<<<<
}
public send_and_read(id, constring[512], ctype) //Where data sent on socket! ctype = 1 or 0 .. 1 means it is client_auth.. and 0.. normal blocking socket reading!
{
new parames[2]
parames[0] = id
write_web(constring) // socket_send :)
//socket_close(g_sckweb) // socket_hz function
if (ctype == 1) {
parames[1] = 1 // timeout value
set_task(2.0, "read_web", 202, parames, 2, "b") // repeated infinite call!
} else {
parames[1] = 10000000 // timeout value
read_web(parames) // normal call!
}
}
connect_web function has same structure as in webservers and sockets example except I used the function above to combine "send and read"..
parames[1] holds timeout value for socket_change in read_web function.
set_task is set as "b" infinite.
I use the "remove_task(202)" in the if statement (socket_change)..
As such users can be authenticated and not cause server to freeze.. Hail to sXe-injected!
The main change was:
PHP Code:
if (socket_change(g_sckweb, parames[1])){
remove_task(202) //Remove the infinite task!
// Do something, socket changed :D
} else {
// No change in socket!
}
socket_change made server wait for too long with higher timeouts. Setting a task at a 1-5s interval and a timeout of 1, would ensure that repetitive regular checking of socket would be done while server is not forced to wait for the change to happen.
in other words, socket_change(socket, timeout) will make the server waits for a change in socket until it reaches timeout or return true for an actual change!
Cheers,
__________________