View Single Post
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 01-17-2010 , 17:59   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #35

Quote:
Originally Posted by AntiBots View Post
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 View Post
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 View Post
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);     } }
__________________

Last edited by Dygear; 01-17-2010 at 18:15. Reason: Added Redone Example.
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear