Raised This Month: $7 Target: $400
 1% 

Module: Sockets_hz ( listenning + nonblocking ) ... working :)


Post New Thread Reply   
 
Thread Tools Display Modes
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-20-2009 , 15:19   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #31

What's wrong with tasks ? They'r needed for TCP connection and hackziner is a bit busy until september or something like that.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 11-12-2009 , 10:08   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #32

A folk remembered me that I modified this module for use in a plugin of mine. The difference is that since socket_open does one operation in blocking mode it still can hang the server. So, this version brings socket_open_non_blocking so all the operations can be done in non blocking mode. Source, win and linux version in the zip file here http://forums.alliedmods.net/showthread.php?t=99516

(Confirmed by hackziner)
__________________

Last edited by joaquimandrade; 11-16-2009 at 14:07.
joaquimandrade is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 11-18-2009 , 18:49   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #33

Quote:
Originally Posted by Exolent[jNr] View Post
I would like to retrieve the IP that is connecting to the socket.
I dont test, buts I know that is like this.... hz then update it....

PHP Code:
// native socket_accept(_socket, &port, ip[], iplen);
static cell AMX_NATIVE_CALL socket_accept(AMX *amxcell *params)  /* 2 param */
{
    
int NewClient;
    
struct sockaddr_in cin
    
int sinsize;
    
int socket params[1];
    
NewClient accept(socket, (struct sockaddr*)&cin, (socklen_t*)&sinsize); //hz

    
if ( NewClient <)
       return -
1;

    
// By Reymon
    
MF_SetAmxString(amxparams[3], inet_ntoa(cin.sin_addr) , params[4]);
    
cell *port MF_GetAmxAddr(amxparams[2]);
    
port ntohs(cin.sin_port);
    
//

    
return NewClient;

__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 11-22-2009 , 18:52   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #34

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!!
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
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
Old 09-18-2010, 05:32
Ramono
This message has been deleted by Ramono. Reason: Solved.
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 09-19-2010 , 12:23   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #36

Quote:
Originally Posted by Exolent[jNr] View Post
Currently, the only way to have this method is supply the IP in the data that I am sending.
I'd like a better way such as socket_info(socket, ip[], len, &port).
I too would like a way to retrieve a sockets IP-adress. Sending it along with the data is impossible as the client connected to my plugin in a http browser.
The function decribed by Exolent[jNr] would be perfect.
__________________
Um, hi.

Last edited by Ramono; 09-19-2010 at 12:44.
Ramono is offline
issen1
Member
Join Date: Jan 2010
Old 10-18-2010 , 06:56   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #37

Quote:
Originally Posted by joaquimandrade View Post
A folk remembered me that I modified this module for use in a plugin of mine. The difference is that since socket_open does one operation in blocking mode it still can hang the server. So, this version brings socket_open_non_blocking so all the operations can be done in non blocking mode. Source, win and linux version in the zip file here http://forums.alliedmods.net/showthread.php?t=99516

(Confirmed by hackziner)
Can someone edit this in the first post, please? I was nearly about to edit hz original package myself. Thank you!
__________________
greets (:
issen1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode