Multi-Thread in sockets! Help please!
Hey guys, you've been a lot of help to me so far. Thanks to you all.
I was using the webservers and sockets example but noticed that whenever the socket would be listening or waiting for some response, the whole server went gaga(freezed until response received.) My solution was to try get receiving of data happens in another thread. But how to do that? I did some research and it only came with 'SQLx multi threading'. Anyone can help me out or propose a better way?.... BIG thanks! |
Re: Multi-Thread in sockets! Help please!
would be very usefull to create a Threaded Sockets Module.
Too bad that i don't have the necesary knowledge to acomplish that. |
Re: Multi-Thread in sockets! Help please!
@DjOptimuS me too..
Well .. I hack'd my way through.. and guess that the most appropriate thing is "not to use socket at all" or "use set_task and make sure data received via sockets ain't event dependent ><" .. I think sXe-injected use set_task on clientputinserver :) I'll do same!! If still, someones found a better way.. let us know. |
Re: Multi-Thread in sockets! Help please!
|
Re: Multi-Thread in sockets! Help please!
Sockets_hz helps on listening, but it blocks the server too. I already tested it.
The function socket_unblock isn't working propely, and, besides, you read the code samples ? You must set an infinite loop task, from short time to short time, like 0.3 seconds, or 0.1 on the sample you gave. Isn't ok. I use sockets to call a HLTV process, using a HLTV code sample finded here on the forums, i adapted the code to Sockets_HZ, but, because of the set task, sometimes i didn't received the challenge id from the HLTV, so Sockets_HZ isn't a solution, a Threaded Sockets Module IS the solution. |
Re: Multi-Thread in sockets! Help please!
Well, take a look at Hackinzer's mIRC server!
|
Re: Multi-Thread in sockets! Help please!
i see that you are from romania, i am from romania too, and i used to work for the biggest hosting provider from romania, and i know that almost all of the cs servers owner, don't understand what socket mean (at least from romania).
If you have the server hosted in Romania, for example a WAR server, and you want to use HLTV on it, but you have the HLTV located in the USA for example, be sure that the HLTV calling functions will hang the server. If you don't know what do you say, don't say it. |
Re: Multi-Thread in sockets! Help please!
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:
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:
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, |
Re: Multi-Thread in sockets! Help please!
sometimes the sockets returns nothing just because the standard infinite loop is too fast, for example 0.1 or 0.2 set_task to listen the socket.
The Sockets_HZ ideea is good, but only if the socket you need to call is relatively close to your server, or maybe on the same server, but in this case, the standard socket will work, because everything is fast. But the problem appears when you need to call something via socket that have ping over 40-50 ms between them |
Re: Multi-Thread in sockets! Help please!
Yes.. the issue comes if it's over 40-50ms latency between the two servers :(
|
| All times are GMT -4. The time now is 23:24. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.