AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] Socket (3.0.1) (https://forums.alliedmods.net/showthread.php?t=67640)

sfPlayer 02-28-2008 00:22

[EXTENSION] Socket (3.0.1)
 
1 Attachment(s)
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

Extreme_One 02-28-2008 05:33

Re: [EXTENSION] Socket
 
So this is compatible with Olly's new IRCRelay v2.0.0 running on Linux?

sfPlayer 02-28-2008 05:58

Re: [EXTENSION] Socket
 
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.

p3tsin 02-28-2008 11:29

Re: [EXTENSION] Socket
 
Simply awesome. I'm running my cupbot with the extension :wink:.

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. :up:

Olly 02-28-2008 13:26

Re: [EXTENSION] Socket
 
Quote:

Originally Posted by sfPlayer (Post 590788)
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 ?

sfPlayer 02-28-2008 20:08

Re: [EXTENSION] Socket
 
@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 ;)

sfPlayer 02-29-2008 01:21

Re: [EXTENSION] Socket
 
Version 2 is out :)

kill0r 03-03-2008 03:20

Re: [EXTENSION] Socket
 
Wow, a stable socket-ext for win&lin, finally :D
great job btw

Olly 03-05-2008 12:37

Re: [EXTENSION] Socket (2.1.0)
 
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.

sfPlayer 03-05-2008 13:21

Re: [EXTENSION] Socket (2.1.0)
 
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.

Extreme_One 03-05-2008 16:55

Re: [EXTENSION] Socket (2.2.0)
 
I'll be really happy if I were able to IRCrelay on my Linux TF2 server.

I hope you get it sussed between you :)

sfPlayer 03-06-2008 02:57

Re: [EXTENSION] Socket (2.2.0)
 
The bug is already fixed and it seems to work so far, expect him to release soon :D

OziOn 03-09-2008 07:02

Re: [EXTENSION] Socket (2.2.0)
 
Ehm, where do I put the files from the socket_src.zip file?

sfPlayer 03-09-2008 07:35

Re: [EXTENSION] Socket (2.2.0)
 
socket_src is the sourcecode archive, you only need socket.zip (windows&linux, ep1&ep2)

p3tsin 03-14-2008 11:11

Re: [EXTENSION] Socket (2.3.0)
 
Nice job fixing the receiving of binary data and other improvements :wink:

Im having some problems when it comes to connecting to hosts that refuse the connection tho; it causes a send or a recv error making the extension choke and unable to receive or send data at all. Even reloading the extension doesnt seem to help, and I have to restart the whole gameserver.

Also, when the host doesnt exist the extension keeps trying to connect to it for a few minutes before timing out, that might be a bit too long.

sfPlayer 03-14-2008 12:00

Re: [EXTENSION] Socket (2.3.0)
 
SocketSetOption(socket, SocketSendTimeout, 10000); should set the timeout for connecting to 10 seconds.

A socket error should not affect other sockets, but due to a special optimization a bug can cause all sockets to malfunction. Please tell me the values of errorType and errorNum in your SocketError callback, I'll look into it.

p3tsin 03-14-2008 17:55

Re: [EXTENSION] Socket (2.3.0)
 
Here we go:
Code:

errorType 4 (Send error), errorNum 111
errorType 6 (Recv error), errorNum 111


sfPlayer 03-14-2008 18:19

Re: [EXTENSION] Socket (2.3.0)
 
I think I found the bug, please test if the attached version works.

p3tsin 03-14-2008 18:36

Re: [EXTENSION] Socket (2.3.0)
 
Awesome, that did the job. :up:

Davethegreat 03-24-2008 14:49

Re: [EXTENSION] Socket (2.3.0)
 
would this version stop sourcebans (which requires v2.0) or no?

sfPlayer 03-24-2008 19:18

Re: [EXTENSION] Socket (2.3.0)
 
Sourcebans doesn't require a socket extension.

[Arnold] 03-26-2008 11:01

Re: [EXTENSION] Socket (2.3.0)
 
Quote:

Originally Posted by sfPlayer (Post 596837)
I think I found the bug, please test if the attached version works.

Did you update the version on the first page? Or is this a just test build?

sfPlayer 03-26-2008 12:04

Re: [EXTENSION] Socket (2.3.0)
 
I'll update later, can't compile on Windows atm

[Arnold] 04-08-2008 08:50

Re: [EXTENSION] Socket (2.3.0)
 
Did you make any progress on a new build? If not, is it safe to use your previously attached version?

sfPlayer 04-08-2008 08:57

Re: [EXTENSION] Socket (2.3.0)
 
It's safe as long as you don't try connecting to unreachable hosts. I'll post a small update in a few hours and a rather large one later which implements SendTo for UDP.

[Arnold] 04-09-2008 06:59

Re: [EXTENSION] Socket (2.3.1)
 
Socket 2.3.1 seems to require glibc 2.4, so it refuses to load on my Debian Etch Linux server with glibc 2.3.6:

Quote:

[08] <FAILED> file "socket.ext.so": /lib32/libc.so.6: version `GLIBC_2.4' not found (required by /opt/gameserv/halflife/hlds_l_source/cstrike/addons/sourcemod/extensions/socket.ext.so)

sfPlayer 04-09-2008 07:19

Re: [EXTENSION] Socket (2.3.1)
 
Thanks, recompiled it without stack protector. It should work with GLIBC >= 2.1.3 now.

[Arnold] 04-09-2008 07:26

Re: [EXTENSION] Socket (2.3.1)
 
Compiled it with gcc-4.1 (edited the Makefile) upon glibc 2.3.6. Worked as well. Thanks!

disconnect81 05-24-2008 09:22

Re: [EXTENSION] Socket (2.3.1)
 
Hello,

I am getting the following errors when I try to use this on my DODS servers along with Olly's IRC Relay. Olly suggestion I post this error here.

However, Im trying to get it to work on my dods servers, and I get the following errors.

L 05/23/2008 - 19:30:54: [irc-relay-core.smx] socket error 5 (errno 10022)
L 05/23/2008 - 19:30:54: [SM] Native "SocketIsConnected" reported: Invalid handle: 16777467
L 05/23/2008 - 19:30:54: [SM] Debug mode is not enabled for "irc-relay-core.smx"However, Im trying to get it to work on my dods servers, and I get the following errors.

L 05/23/2008 - 19:30:54: [irc-relay-core.smx] socket error 5 (errno 10022)
L 05/23/2008 - 19:30:54: [SM] Native "SocketIsConnected" reported: Invalid handle: 16777467
L 05/23/2008 - 19:30:54: [SM] Debug mode is not enabled for "irc-relay-core.smx"

L 05/24/2008 - 09:24:25: [irc-relay-core.smx] socket error 5 (errno 10022)
L 05/24/2008 - 09:24:25: [irc-relay-core.smx] socket error 3 (errno 10038)
L 05/24/2008 - 09:24:25: [SM] Native "CloseHandle" reported: Handle 10000fb is invalid (error 1)
L 05/24/2008 - 09:24:25: [SM] Displaying call stack trace for plugin "irc-relay-core.smx":
L 05/24/2008 - 09:24:25: [SM] [0] Line 1231, irc-relay-core.sp::OnSocketError()


Cheers,

Disconnect

disconnect81 05-25-2008 18:13

Re: [EXTENSION] Socket (2.3.1)
 
I just wanted to note, I set up a fresh DODS server today. Installed metamod, soucemod, irc relay, and this socket extension... nothing else. I still get the same issues. :(

maitredede 05-26-2008 06:09

Re: [EXTENSION] Socket (2.3.1)
 
Hi,

This looks like a really interesting extension with a great potential...

Do you have more doc/samples ?

I would like to create a plugin that uses this lib, but I have some questions...
- How can I do to have a request/reply mechanism for a plugin ? Like if a player say "meteo" and then the plugin connects to a meteoserver, and reply back to player ?
- Can you add native text functions to make communication easier, like Readline read buffer until found a LF char). So communication with a telnet server would become really easy, and someone could develop a webserver ;)

Thanks

gM@X 05-27-2008 09:01

Re: [EXTENSION] Socket (2.3.1)
 
in thread IRC Relay v2.0.1

Quote:

Originally Posted by gM@X (Post 629524)
don't work
Quote:

L 05/24/2008 - 11:55:58: SourceMod error session started
L 05/24/2008 - 11:55:58: Info (map "gg_autumn") (file "errors_20080524.log")
L 05/24/2008 - 11:55:58: [irc-relay-core.smx] socket error 3 (errno 10049)
L 05/24/2008 - 12:05:52: Error log file session closed.
Quote:

SourceMod Version Information:
SourceMod Version: 1.0.1.2166
JIT Version: JIT (x86), 1.0.1.2166
JIT Settings: Generic i686
http://www.sourcemod.net/
also don't work with 1.0.0

Quote:

[SM] Listing 44 plugins:
01 "Admin File Reader" (1.0.1.2166) by AlliedModders LLC
02 "SQL Admins (Threaded)" (1.0.1.2166) by AlliedModders LLC
03 "Admin Help" (1.0.1.2166) by AlliedModders LLC
04 "Admin Menu" (1.0.1.2166) by AlliedModders LLC
05 "Advertisements" (0.2) by Tsunami
06 "Anti-Flood" (1.0.1.2166) by AlliedModders LLC
07 "Basic Chat" (1.0.1.2166) by AlliedModders LLC
08 "Basic Comm Control" (1.0.1.2166) by AlliedModders LLC
09 "Basic Commands" (1.0.1.2166) by AlliedModders LLC
10 "Basic Info Triggers" (1.0.1.2166) by AlliedModders LLC
11 "Basic Votes" (1.0.1.2166) by AlliedModders LLC
12 "Crazy Drug" (0.1) by Fredd
13 "Fun Commands" (1.0.1.2166) by AlliedModders LLC
14 "Fun Votes" (1.0.1.2166) by AlliedModders LLC
15 "Damage report" (1.1.8) by [30+]Gemeni
16 "HLstatsX Plugin" (2.1) by Tobi17
17 "HANSE Reserved Slots" (1.3.1-r1) by red!
18 "IRC Relay - Admin Commands Module" (2.0.0) by Olly
19 "IRC Relay - Auth Module" (2.0.1) by Olly
20 "IRC Relay - Bacon" (2.0.1) by Olly
21 "IRC Relay - Base Commands" (2.0.1) by Olly
22 "IRC Relay - Game Players" (2.0.1) by Olly
23 "IRC Relay - Relay Module" (2.0.1) by Olly
24 "IRC Relay - Game Info Module" (2.0.1) by Olly
25 "IRC Relay - Core Plugin" (2.0.1) by Olly
26 "IRC Relay - Steam Community" (2.0.1) by Olly
27 "Nextmap" (1.0.1.2166) by AlliedModders LLC
28 "SlapSlay Commands" (1.0.1.2166) by AlliedModders LLC
29 "Players Votes" (1.2.2) by pZv!
30 "Quake Sounds" (1.8) by dalto
31 "RateChecker" (0.2) by pRED*
32 "Reserved Slots" (1.0.1.2166) by AlliedModders LLC
33 "Rock The Vote" (1.0.1.2166) by AlliedModders LLC
34 "Say Sounds" (1.19) by Hell Phoenix
35 "PlayersList" (0.3) by O!KAK
36 "SourceBans" by SteamFriends Development Team
37 "SourceBans Sample Plugin" (1.0.0 RC2) by SteamFriends Development Team
38 "SQL Admin Manager" (1.0.1.2166) by AlliedModders LLC
39 "SrcTV demorecord" (0.1) by O!KAK
40 "Teamswitch Menu" (0.2.6) by R-Hehl
41 "Teamswitch Menu" (0.2.4) by R-Hehl
42 "TeamIdRetriver" (0.0.1) by R-Hehl
43 "Matrix Plugin" (1.0) by V0gelz
44 "Weapon Logging" (2.1) by Tobi17
databases.cfg
Code:

"Databases"
{
"driver_default"                "mysql"
       
        "sourcebans"
        {
                "driver"                        "default"
                "host"                                "192.168.111.11"
                "database"                        "sourcebans"
                "user"                                "sourcebans"
                "pass"                                "7SctbQW6D3bDTNfE"
                //"timeout"                        "0"
                "port"                        "3306"
        }


        "irc_relay"
        {
                "driver"            "mysql"
                "host"            "192.168.111.11"
                "database"      "sourcebans"
                "user"            "sourcebans"
                "pass"            "7SctbQW6D3bDTNfE"
                //"timeout"            "30"
        }
}

PS
Socket (2.3.1) installed

Quote:

Originally Posted by Olly (Post 629581)
#10049 normally means that you either have the IP set to 0.0.0.0, or the port set to 0

Quote:

Originally Posted by gM@X (Post 630453)
thx
change irc hostname to 192.168.111.10 (another irc server in LAN)
start server with ip 0.0.0.0

i get another error:
Quote:

L 05/27/2008 - 00:17:56: SourceMod error session started
L 05/27/2008 - 00:17:56: Info (map "gg_autumn") (file "errors_20080527.log")
L 05/27/2008 - 00:17:56: [irc-relay-core.smx] socket error 6 (errno 0)
L 05/27/2008 - 00:18:48: Error log file session closed.
PS
ircrelay.cfg
Code:

//*********************************************************
//*  IRC Relay Core

//*********************************************************

irc_server "192.168.111.10"
irc_port 6697
irc_password ""
irc_nickname "CSSBot"

// NAME CANNOT CONTAIN SPACES, OR QUOTES (This will be the bot trigger too!)
irc_name "hl.homeftp.org"
// The delay from each message dispatch from the message queue
irc_flood_limit 0.5
// Group list for triggers
irc_trigger_groups "css"
// The type of channel to send /irc messages from in-game to
//    * 1 = Public Channels
//    * 2 = Private Channels
//    * 3 = Both types
irc_relay_replytype 3
// Display raw IRC data in console, and log files
irc_debug 1
// Enable sending of colour codes
irc_color 1
//*********************************************************
//*  Authentication Module
//*********************************************************

// The auth string to send (Dont remove %s, that will be replaced by username/pass)
// GameSurge (ChanServ): AUTHSERV AUTH %s %s
// QuakeNet (Q): PRIVMSG [email protected] :auth %s %s
irc_auth_string "AUTHSERV AUTH %s %s"
// AuthServ login details (optional)
irc_auth_username "CSSBot"
irc_auth_password "csspassword"

//*********************************************************
//*  Sets the access levels required to run each command (0-300)
//*********************************************************
// Add User
irc_xs_adduser 300
// Make the relay speak in the channel
irc_xs_say 300
// Make the relay reload a module (SHOULD BE 300!)
irc_xs_reload 300
// Get player list
irc_xs_players 0
// Get information on a player
irc_xs_playerinfo 0
// Send a message to everyone in the server
irc_xs_msg 200
// Makes the relay perform an action (/me)
irc_xs_act 200
// Makes the relay perform an action (/me)
irc_xs_act 200
// Send a message to one player in the server
irc_xs_page 100
// Make the relay join a new channel
irc_xs_join 300
// Make the relay part from a channel
irc_xs_part 300
// == ADMIN COMMANDS ==
// Kick a player from the server
irc_xs_kick 150
// Bans a player from the server
irc_xs_ban 160
// Executes a command on the server (RCON)
irc_xs_rcon 250


Quote:

Originally Posted by Olly (Post 630480)
I have no idea what the error numbers in socket are, you should post that in the socket extension topic


disconnect81 05-27-2008 09:42

Re: [EXTENSION] Socket (2.3.1)
 
gM@X, what game are you getting these errors on?

gM@X 05-27-2008 11:25

Re: [EXTENSION] Socket (2.3.1)
 
Counter-Strike: Source

disconnect81 06-03-2008 16:15

Re: [EXTENSION] Socket (2.3.1)
 
Looks like the developer isnt around :(

sfPlayer 06-11-2008 06:46

Re: [EXTENSION] Socket (2.3.1)
 
he was busy the past few weeks, i'll look into it.

disconnect81 06-12-2008 08:39

Re: [EXTENSION] Socket (2.3.1)
 
Quote:

Originally Posted by sfPlayer (Post 637561)
he was busy the past few weeks, i'll look into it.

Grrreat, I really want to get this working on my dods and dodsbeta servers :)

sfPlayer 06-28-2008 08:30

Re: [EXTENSION] Socket (2.3.1)
 
Quote:

Originally Posted by gM@X (Post 630698)

0 means "No Error", but this way I can't get the received size. I can probably ignore the error, but idk if it'll fix it. Please contact me for a test build which tries to fix it for verification.

sfPlayer 06-28-2008 11:28

Re: [EXTENSION] Socket (2.3.1)
 
Quote:

Originally Posted by maitredede (Post 630250)
- How can I do to have a request/reply mechanism for a plugin ? Like if a player say "meteo" and then the plugin connects to a meteoserver, and reply back to player ?

check the example.sp for how to send and receive messages. You'll have to write your own server application for the gameserver to connect to. If #2 is also a gameserver you can do it similar to listenexample.sp

Quote:

Originally Posted by maitredede (Post 630250)
- Can you add native text functions to make communication easier, like Readline read buffer until found a LF char). So communication with a telnet server would become really easy, and someone could develop a webserver ;)

i'll look into it, but you can also implement it in a fairly easy way in sourcepawn.

flook 07-09-2008 06:34

Re: [EXTENSION] Socket (2.3.1)
 
Hello

Im trying to getting Socket installed on my server, but im a noob at such things. But when i got it installed, and try to load it i get this error:

[06] <FAILED> file "socket.ext.so": /home/game1/cstrike/addons/sourcemod/extensions/socket.ext.so: cannot open shared object file: No such file or directory

When i check the directory, it seems like its ok, but i don't got: /home/game1/

i just got: ftp://<IP>/cstrike/...

Can anyone help me please?

Thx :)


All times are GMT -4. The time now is 17:11.

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