Quote:
Originally Posted by AntiBots
Any want a update of this?? I am working and I have time to add things if someone need it.
like a hacer to get host name. and stuff like that.
PM me or write me here!!
Good Bye!!
|
Yeah, that would be awesome!
Code:
socket_listenfw(szAddress, iPort, SOCKET_TCP, iError, 'fwFunction');
This should also set the plugin to an automatic non-blocking mode by calling that function.
Quote:
Originally Posted by Bugsy
A forward for incoming data would be nice so it can be handled as it arrives. This would eliminate the need for set_tasks\loops for socket_change checks for incoming data.
|
Yeah, I'm thinking about posting an enhancement request to move all of these functions into the core of AMX Mod X, as they really should of been there in the first place.
Quote:
Originally Posted by hackziner
public auto_accept_reply() {
new this_chaussette;
if((this_chaussette=socket_accept(listening_s ocket))<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)
}
}
[/php]
|
Your sending this to a HTTPd server? Should you not be sending a HTTP Header?
Code:
new cmd[1024]
server_print("Accept/send/close")
format(cmd,1024,"Something to send")
socket_send(this_chaussette,cmd,1024)
socket_close(this_chaussette)
I changed around your example, here's the code (I have no idea if this works by the way. but it does compile, so that's a plus).
Code:
#include <amxmodx>
#include <sockets_hz>
new g_iSocket, szAddress[] = "amxmodx.org", iPort = 80, iError;
public plugin_init() {
register_plugin("Sockets Example", "0.2", "hackzinger + Dygear");
g_iSocket = socket_listen(szAddress, iPort, SOCKET_TCP, iError);
socket_unblock(g_iSocket);
set_task(1.0, "fwSocketAccept", 0, "", 0, "b");
}
public plugin_end() socket_close(g_iSocket);
public fwSocketAccept() {
new iSocket;
if( (iSocket = socket_accept(g_iSocket)) < 0 )
server_print("No pending connection");
else {
new szHttpReq[128], iReqSz = (sizeof(szHttpReq) - 1);
format(szHttpReq, iReqSz, "GET / HTTP/1.1^nHost: %s^n^n", szAddress);
socket_send(iSocket, szHttpReq, iReqSz);
socket_close(iSocket);
}
}
__________________