Quote:
Originally Posted by Relaxing
Take a look at this thread and come up with a way to stop using set_task every 0.1s.
https://forums.alliedmods.net/showthread.php?t=169315
Spoiler
Code:
# AMXX_VERSION_NUM < 190
#define _socket_get(%1) socket_change(%1)
#else
#define _socket_get(%1) socket_is_readable(%1)
public plugin_init(){
if (Initialize())
set_task(0.1, "tsk_Chat", .flags = "b")
else
set_fail_state("[Critical] AmxXDMT: Failed to initialze the (socket) server.");
}
// @ public cmd_Chat(id) increase the array size to 188
public tsk_Chat(){
if (_socket_get(g_iServer, 0)){
//
}
bool:Initialize(){
new temp;
return bool:(socket_open("127.0.0.1", PORT, _, temp));
}
|
You probably meant:
"Take a look at this thread and come up with a way to stop using set_task every 0.1s by using a module that does pretty much the same thing".
Sockets are a way of sending/receiving data over a network. Networks are unreliable and have lots of delays. You can not know when data is available without waiting for it, which means continuously checking to see if it's available or blocking until it is. Blocking in the main thread is a really bad idea since the server will "freeze" until the data arrives.
__________________