Quote:
I don't get it, so all u have to do is call
socket_unblock(_socket)
then
socket_accept(_socket)
and it doesnt block?
or..?
Anyway, can somone compile this for win32 please?
|
Yep it's the good way
A little sample:
PHP Code:
#include <amxmodx>
#include <sockets_hz>
new listening_socket
public plugin_init() {
new error //you're the error
register_plugin("demo", "0.1", "hackziner")
listening_socket = socket_listen("127.0.0.1",8081,SOCKET_TCP,error)
socket_unblock(listening_socket)
server_print("LISTENNING ANY IP ON PORT %d",8081)
set_task(1.0,"auto_accept_reply",0,"",0,"b")
}
public plugin_end ()
{
socket_close(listening_socket) //very very important !!
}
public auto_accept_reply() {
new this_chaussette;
if((this_chaussette=socket_accept(listening_socket))<0)
{
server_print("No pending connection")
}
else
{
new cmd[1024]
server_print("Accept/send/close")
format(cmd,1024,"Something to send")
socket_send(this_chaussette,cmd,1024)
socket_close(this_chaussette)
}
}
There is little problem with a definition on win32 I'm going to check the problem ...
__________________