Raised This Month: $2 Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hackziner
Senior Member
Join Date: Sep 2006
Location: France
Old 08-25-2007 , 13:30   Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #1

It's a modification of the socket module.

I've added 3 functions.

PHP Code:
/* Opens a new listenning connection bind to hostname:port via protocol (either SOCKET_TCP or SOCKET_UDP),
 * returns a socket (positive) or negative or zero on error.
 * States of error:
 * 0 - no error
 * 1 - error while creating socket
 * 2 - couldn't resolve hostname
 * 3 - couldn't connect to given hostname:port 
*/

native socket_listen(const _hostname[], _port_protocol SOCKET_TCP, &_error); 
PHP Code:
/* Set a socket in unblocking mode */

native socket_unblock(_socket); 
PHP Code:
native socket_close(_socket);

/* Accept a connection on a listenning socket 
 * returns a socket (positive) or negative or zero on error. */

native socket_accept(_socket); 
With UDP you've just to create a listenning socket to get incoming messages and create a socket to reply.

With TCP you've to create a listenning socket and accept connections.

To avoid socket_accept block. Set the listenning socket to nonblocking mode with socket_unblock.


Todo:
add: incoming packet address in socket_accept
add: function to see the address when receive a package of a listenning socket.
Attached Files
File Type: inc sockets_hz.inc (2.2 KB, 1528 views)
File Type: zip sockets_hz.zip (56.7 KB, 1845 views)
File Type: so sockets_hz_amxx_i386.so (11.3 KB, 3043 views)
__________________

Last edited by hackziner; 03-09-2009 at 18:46.
hackziner is offline
Send a message via ICQ to hackziner Send a message via AIM to hackziner Send a message via MSN to hackziner Send a message via Yahoo to hackziner Send a message via Skype™ to hackziner
toazron1
Senior Member
Join Date: Oct 2006
Old 08-25-2007 , 13:46   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #2

Can you add an example of this in action?
__________________
toazron1 is offline
Send a message via AIM to toazron1
hackziner
Senior Member
Join Date: Sep 2006
Location: France
Old 08-25-2007 , 14:50   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #3

...
__________________

Last edited by hackziner; 08-25-2007 at 16:26.
hackziner is offline
Send a message via ICQ to hackziner Send a message via AIM to hackziner Send a message via MSN to hackziner Send a message via Yahoo to hackziner Send a message via Skype™ to hackziner
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-25-2007 , 14:53   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #4

Nice work hackziner!

@toazron1 - http://forums.alliedmods.net/showpos...1&postcount=16
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 08-25-2007 , 15:07   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #5

Quote:
Originally Posted by Alka View Post
Thanks
__________________

Last edited by toazron1; 08-25-2007 at 15:59.
toazron1 is offline
Send a message via AIM to toazron1
hackziner
Senior Member
Join Date: Sep 2006
Location: France
Old 08-25-2007 , 15:57   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #6

I'm very sorry but people keep asking thing like this ... and I'm keep replying I've no enough time ...

You should ask to ramono his code with the new socket_unblock function ...
__________________

Last edited by hackziner; 08-25-2007 at 16:26.
hackziner is offline
Send a message via ICQ to hackziner Send a message via AIM to hackziner Send a message via MSN to hackziner Send a message via Yahoo to hackziner Send a message via Skype™ to hackziner
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 08-29-2007 , 10:04   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #7

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?
__________________
Um, hi.
Ramono is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 08-29-2007 , 10:20   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #8

There is a win32 in the other thread, however, I'm not 100% positive that it is the newest version.
__________________
toazron1 is offline
Send a message via AIM to toazron1
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 08-29-2007 , 10:52   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #9

Quote:
Originally Posted by toazron1 View Post
There is a win32 in the other thread, however, I'm not 100% positive that it is the newest version.
It isnt.
__________________
Um, hi.
Ramono is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-29-2007 , 11:58   Re: Module: Sockets_hz ( listenning + nonblocking ) ... working :)
Reply With Quote #10

Quote:
Originally Posted by toazron1 View Post
There is a win32 in the other thread, however, I'm not 100% positive that it is the newest version.
Hey! You stole my old avatar!
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 17:21.


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