Monthly Target: $400 Donations: $23
 5% 

[EXTENSION] Socket (3.0.1)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-28-2008 , 00:22   [EXTENSION] Socket (3.0.1)
Reply With Quote #1

latest version: http://forums.alliedmods.net/attachm...chmentid=83286

This extension provides networking functionality for SourceMod scripts. It's a heavily modified fork of Olly's sockets extension 2.0.0.

It's supposed to be stable. If it crashes please post the srcds debug.log and the plugin's sourcecode which makes use of the socket extension.

You need at least SourceMod 1.0.3!

Look at socket.inc for development documentation.


Developer Notes
  • Make sure to use all 3 Set...Callback functions on sockets spawned by listen sockets before using the child sockets.
  • Don't use ports below 1024 for listening sockets due to permission restrictions on linux
  • Do not expect SocketConnect() and SocketSend() to be atomic operations, both might not have finished yet after they were executed. Always use the socket connect-callback as shown in the example to start sending data.
  • Don't forget to close the socket handle

Usage example


The example example.sp downloads a file via http to <modfolder>/dl.htm
The example listenexample.sp provides a simple echo server. Use telnet <serverip> 50000 to connect to it.
The examples are located at addons/sourcemod/scripting in the socket.zip file.


Changelog

Version 2.4.0+
  • check the git(web) shortlog (see sourcecode repository url)
Version 2.3.1
  • fixed an error handling bug
Version 2.3.0
  • Added SocketDisconnect()
  • fixed a crashbug on unload
  • fixed receiving binary data
  • improved error handling
  • stricter condition checking
  • fixed a possible race condition in SocketSetSendqueueEmptyCallback()
Version 2.2.0
  • Added optional SendqueueEmpty callback which allows an application to correctly close the connection after all data has been sent
  • Fixed SocketSend() calculating the packet size 1 byte too large if it was not specified explicitly (thx to olly for finding the bug)
Version 2.1.0
  • Added SocketSetOption()
  • Added optional packet/callback concatenation mechanism to reduze the amount of receive callbacks for large transfers
  • removed Metamod:Source dependency (-> AddGameFrameHook)
  • improved sending of large chunks of data
  • everything should be binary safe now (support for sending/receiving 0x00), read the documentation for details
  • moved sending and connecting into threads
  • a few bugfixes
Version 2.0.0
  • Added SocketBind() and SocketListen() -> listening socket support
  • major API change to unify and optimize the socket usage
  • some additional small changes
Version 1.0.0
  • initial public release

Sourcecode repository


http://player.to/gitweb/index.cgi?p=sm-ext-socket.git

- Clone my public repository:
git clone git://player.to/sm-ext-socket.git <directory>

Download

latest version:
http://forums.alliedmods.net/attachm...chmentid=83286
Attached Files
File Type: zip socket_3.0.1.zip (633.2 KB, 80577 views)

Last edited by sfPlayer; 03-06-2011 at 10:06. Reason: version 3.0.1
sfPlayer is offline
Extreme_One
Veteran Member
Join Date: Nov 2006
Old 02-28-2008 , 05:33   Re: [EXTENSION] Socket
Reply With Quote #2

So this is compatible with Olly's new IRCRelay v2.0.0 running on Linux?
__________________
Extreme_One is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-28-2008 , 05:58   Re: [EXTENSION] Socket
Reply With Quote #3

No, but I've modified it to be compatible.

IRCRelay somehow doesn't work, the initial IRC communication works (nickname, ping-pong, etc.) and it receives everything from the socket but doesn't respond back/react on commands. My debugging shows that it doesn't even call SocketSend() after it receives PRIVMSG, so it's a bug/configuration issue in the plugin and not in the extension.
sfPlayer is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 02-28-2008 , 11:29   Re: [EXTENSION] Socket
Reply With Quote #4

Simply awesome. I'm running my cupbot with the extension .

A few questions tho:
1) In the include file, the native SetSocketArg takes any:arg but the forwards output it as Handle:arg ... why?
2) Does it support sending and receiving the \x00 char?

Good work.
__________________
plop
p3tsin is offline
Olly
Senior Member
Join Date: Mar 2007
Location: UK
Old 02-28-2008 , 13:26   Re: [EXTENSION] Socket
Reply With Quote #5

Quote:
Originally Posted by sfPlayer View Post
No, but I've modified it to be compatible.

IRCRelay somehow doesn't work, the initial IRC communication works (nickname, ping-pong, etc.) and it receives everything from the socket but doesn't respond back/react on commands. My debugging shows that it doesn't even call SocketSend() after it receives PRIVMSG, so it's a bug/configuration issue in the plugin and not in the extension.
Well i can tell you that its not the plugin lol, because it works with my sockets extension, and we have had it running for weeks.

All data being sent to the socket in ircrelay is queued, so that relays dont flood off the server.

Also this wont work with a local database, because you removed all of the md5 stuff from the extension.

What happened to BindSocket ?
__________________
Tumblr Me: http://raspberryteen.tumblr.com


// Yarrrr!

Last edited by Olly; 02-28-2008 at 13:29.
Olly is offline
Send a message via MSN to Olly
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-28-2008 , 20:08   Re: [EXTENSION] Socket
Reply With Quote #6

@p3tsin
1) I forgot to update these, output will also be any:arg soon
2) currently not, but i'll look into it

@olly
You are calling send with a closed socket, that can't work as expected (this only seems to happen on startup if somebody didn't set the irc_server cvar before, the irc-relay config seems to require manual execution through the server.cfg). I added additional checking to SocketSend if the socket is closed and it correctly throws an error.

The md5 stuff should go into another extension, it makes no sense to put it in here. You can also store the passwords unhased like you do for SQLite.

BindSocket will be back soon, including some more natives to create server applications on gameservers ;)

Last edited by sfPlayer; 02-28-2008 at 20:10.
sfPlayer is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-29-2008 , 01:21   Re: [EXTENSION] Socket
Reply With Quote #7

Version 2 is out

Last edited by sfPlayer; 03-02-2008 at 09:06.
sfPlayer is offline
kill0r
Junior Member
Join Date: Jun 2007
Old 03-03-2008 , 03:20   Re: [EXTENSION] Socket
Reply With Quote #8

Wow, a stable socket-ext for win&lin, finally
great job btw
kill0r is offline
Olly
Senior Member
Join Date: Mar 2007
Location: UK
Old 03-05-2008 , 12:37   Re: [EXTENSION] Socket (2.1.0)
Reply With Quote #9

I am going to stop my socket plugin, as yours has more features, more stable, etc....

So im converting IRC Relay to your ext, but it never gets past sending PONG :.....\n\r\n\r

I have checked if the socket is connected, etc, and it seems to be, but it seems your extension is not sending the packet. I have debugged my plugin as far as i can, and I see no problem with sending the 'pong' packet.
__________________
Tumblr Me: http://raspberryteen.tumblr.com


// Yarrrr!
Olly is offline
Send a message via MSN to Olly
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 03-05-2008 , 13:21   Re: [EXTENSION] Socket (2.1.0)
Reply With Quote #10

My extention is actually only an enhanced version of yours ;)

Please add debug output right before you call SocketSend() and use wireshark (or any other packet sniffer) to check if you actually call SocketSend() and the ext sends the packet.

If neither the error callback gets fired nor a native error gets triggered it's a bug, please send me the sourcecode for further investigation.

Last edited by sfPlayer; 03-05-2008 at 13:27.
sfPlayer 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 16:20.


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