1. Post #1
    Anders1's Avatar
    September 2005
    82 Posts
    This is a full-featured port of LuaSocket for GMod. I've tried a simple socket thing, which worked out just fine.

    spbogie posted:
    I have modified the Lua files to fix the problems with using the sub-modules (socket.http, socket.ftp, etc...).

    Required Changes:
    Code:
    moved socket.lua to /socket/socket.lua
    
    added socket.lua
        includes /socket/*.lua in necessary order
    
    changed /socket/mime.lua
        removed reqiure( "io" ) - unused, not available in gmod
    
    changed /socket/smtp.lua
        Line 33: DOMAIN = os.getenv("SERVER_NAME") or "localhost"
            to: DOMAIN = "localhost"
        os.getenv not available in gmod
    Calling require( "socket" ) will load all sub-modules as well.

    Fix is available at http://people.msoe.edu/~bogies/luasocket_fix.zip.
    Includes only modifications made, simply extract over existing install.
    Installation instructions:

    Extract that archive in garrysmod/lua/includes/modules.

    You will need the VS2008 runtime libs, or else you'll get a strange error while loading: http://www.microsoft.com/downloads/d...displaylang=en

    Don't ask any questions unless you've installed that (and rebooted)

    Usage:

    Just like LuaSocket, see this for a reference: http://www.tecgraf.puc-rio.br/~diego...reference.html

    Don't forget forget to use non-blocking sockets (set timeout to 0) or else GMod freezes while waiting for data!

    Source code:

    It's a VS 2008 project, should work in the Express version.

    Thanks to:

    Sechs - helped me with testing in #luahelp
    Jinto - provided the Lua import library

    Small example:

    require("socket")
    local s = socket.connect("www.google.com", 80)
    s:send("GET / HTTP/1.1\n")
    s:send("Host: www.google.com\n")
    s:send("User-Agent: GMod10\n")
    s:send("Connection: Close\n")
    s:send("\n")
    local line = s:receive('*line')
    print(line)
    s:close()

    I don't know if that is correct but it should give you an idea about how it's used. You don't even have to use it manually, there are some helper modules too (http, smtp, ftp), but they don't seem to work. they probably would with some modification.
    Reply With Quote Edit / Delete Reply Sweden Show Events Lua King Lua King x 4Useful Useful x 2Optimistic Optimistic x 1 (list)

  2. Post #2
    Gold Member
    anklyne's Avatar
    December 2005
    780 Posts
    I'm curious as to what kind of things this could be used for/what it does. I'm guessing this is one of those things that other programmers will use to make something cool and I'm not a programmer, so this is of no use to me.

    Is it something you'd use to send commands and info from server-client and back or something?

  3. Post #3
    Anders1's Avatar
    September 2005
    82 Posts
    anklyne posted:
    I'm curious as to what kind of things this could be used for/what it does. I'm guessing this is one of those things that other programmers will use to make something cool and I'm not a programmer, so this is of no use to me.

    Is it something you'd use to send commands and info from server-client and back or something?
    You could make anything that uses the internet with this. You could clone a server onto another (send all prop info etc), make a simple web browser, send email, anything...

  4. Post #4
    Gold Member
    Xera's Avatar
    November 2006
    3,097 Posts
    Awesome. :)

  5. Post #5
    Anders1's Avatar
    September 2005
    82 Posts
    I'd really appreciate it if anyone tried this out, I have no idea if it'll even load on other computers.
    Reply With Quote Edit / Delete Reply Sweden Show Events Disagree Disagree x 1 (list)

  6. Post #6
    tjl
    tjl's Avatar
    February 2006
    327 Posts
    Woo hoo, now I can finally make mailbomb script.

  7. Post #7
    Gold Member
    TheFoxz's Avatar
    December 2006
    344 Posts
    This will prove useful :D
    Reply With Quote Edit / Delete Reply Netherlands Show Events Agree Agree x 1 (list)

  8. Post #8
    nonedead's Avatar
    May 2006
    15 Posts
    Quick question, I use VS2008E and what type of project (VB, C++, WD)I know it is not C#. Please clarify this for me. I have limited HD space and do not want to delete alot of files.

  9. Post #9
    Anders1's Avatar
    September 2005
    82 Posts
    It's C++

  10. Post #10
    Sakayd's Avatar
    December 2006
    24 Posts
    Nice job :)

  11. Post #11
    Anders1's Avatar
    September 2005
    82 Posts
    nonedead posted:
    Quick question, I use VS2008E and what type of project (VB, C++, WD)I know it is not C#. Please clarify this for me. I have limited HD space and do not want to delete alot of files.
    You don't need the source code if you're not planning to modify the DLL itself

  12. Post #12
    Gold Member
    RabidToaster's Avatar
    October 2006
    153 Posts
    With both this and the old gm_socket dll whenever I try and use it, it'll create a socket fine, but when I try and do something it'll tell me the socket is closed.

  13. Post #13
    Anders1's Avatar
    September 2005
    82 Posts
    RabidToaster posted:
    With both this and the old gm_socket dll whenever I try and use it, it'll create a socket fine, but when I try and do something it'll tell me the socket is closed.
    Then you're doing something wrong (show me the source code)

  14. Post #14
    picwizdan's Avatar
    September 2007
    33 Posts
    Exactly what I need for cross-server communication.

  15. Post #15
    phenex's Avatar
    August 2005
    53 Posts
    Excellent work, now I have to make a porn spidering script. I think I'll call it "GPorn".
    Reply With Quote Edit / Delete Reply United States Show Events Funny Funny x 1 (list)

  16. Post #16
    Anders1's Avatar
    September 2005
    82 Posts
    It was reported to me that the included LUA modules (socket.http) etc aren't found by require(), so you'll have to figure that out if you need those. Shouldn't be too hard I guess.

  17. Post #17
    Anders1's Avatar
    September 2005
    82 Posts
    My site is currently down, but I'll upload the stuff somewhere else later!

  18. Post #18
    Gold Member
    tad2020's Avatar
    December 2006
    163 Posts
    Does this one's http module override the gmod one?

  19. Post #19
    Anders1's Avatar
    September 2005
    82 Posts
    Probably not

  20. Post #20
    Gold Member
    hegrec's Avatar
    April 2006
    266 Posts
    How would you create a tcp server on a garrysmod game server and have it listen for incoming data but not lock up?

    Basically have the garrysmod server realize 'Hey! someone is connecting' at any point in time without the server locking up.

  21. Post #21
    Gold Member
    DarkSpider's Avatar
    July 2006
    816 Posts
    Anders1 posted:
    I'd really appreciate it if anyone tried this out, I have no idea if it'll even load on other computers.

    After eight hours of fiddling with this, i can tell you that it works. I have it currently set up for Server 2 Server chat on all my servers. It is much better than a mysql query looking for new text. You are awesome man thanks.

  22. Post #22
    Anders1's Avatar
    September 2005
    82 Posts
    hegrec posted:
    How would you create a tcp server on a garrysmod game server and have it listen for incoming data but not lock up?

    Basically have the garrysmod server realize 'Hey! someone is connecting' at any point in time without the server locking up.
    You should do something like :settimeout(0) on the socket, I'm not actually quite sure. See the LuaSocket reference.

  23. Post #23
    mattdaemon's Avatar
    December 2006
    4 Posts
    This could be usefull for someone that has two dedicated servers and get them to link each other together. Making it even faster to run like an 8 man server

  24. Post #24
    Gold Member
    DarkSpider's Avatar
    July 2006
    816 Posts
    Or use the udp version and send data between servers and run a 128 man server!

  25. Post #25
    Gold Member

    July 2006
    1,963 Posts
    This looks too useful for me. Couldn't you upload the files to SpeedyShare or somewhere?

  26. Post #26
    Anders1's Avatar
    September 2005
    82 Posts
    I already uploaded them to garrysmod.org

    Edit:

    What the hell, seems like the files were deleted...

  27. Post #27
    Gold Member
    Neico's Avatar
    October 2005
    104 Posts
    Anders1 posted:
    I already uploaded them to garrysmod.org

    Edit:

    What the hell, seems like the files were deleted...

    if you don't mind:

    http://neic0.de/gmod/gm_luasocket_rc1.zip
    http://neic0.de/gmod/gm_luasocket_source.zip

    i think those ones was that files right?

  28. Post #28
    Anders1's Avatar
    September 2005
    82 Posts
    Yep, thanks! Would have had to boot VMware otherwise.

  29. Post #29
    picwizdan's Avatar
    September 2007
    33 Posts
    DarkSpider posted:
    Or use the udp version and send data between servers and run a 128 man server!
    Have fun with that, 128 player deathmatch, and lots of bandwidth consumption.
    Not only ridiculously hectic to play in, but also will use a shitload of bandwidth if not optimized fully.

    I'm gonna try this module out this weekend if I can, it looks really good for some active communication that I need to do.

  30. Post #30
    Gold Member
    DarkSpider's Avatar
    July 2006
    816 Posts
    Yea, my server starts to stutter if i have 64 in it and they are all firing so i doubt 128 will work. Maybe in a year or so.

  31. Post #31
    SamuraiMush's Avatar
    April 2008
    4 Posts
    Code:
    error loading module 'luasocket' from file 'c:\program files\serverdoc\gmod_xdl\
    server\srcds\orangebox\garrysmod\lua\includes\modules\gm_luasocket.dll':
            system error 14001
    This is what I get when trying to load the module.

    EDIT: Sorry I hadn't gotten the libraries. Everything works fine so far, however grasping IRC protocol is somehow too difficult for me. All that works is the USER message, nothing else yields a reply.

  32. Post #32
    Anders2's Avatar
    January 2006
    1 Posts
    Here's a small IRC protocol guide:

    To connect to the server, port 6667:

    USER username . . :The Real Name (appears in whois)
    NICK yournick

    You should then get a PING somethingrandom, send PONG somethingrandom back

    Then you get stuff like

    :server.com 001 blahblah, when you get 001 it means you can JOIN channels

    use PRIVMSG target :message blah blah to send a message

    Code:
    < NOTICE AUTH :*** blah blah ignore this stuff
    > USER anders . . :Anders
    > NICK anders_lua
    < PING :123568
    > PONG :123568
    < lots of junk, ignore this
    < :server.com 001 <junk>
    > JOIN #anders
    < some junk about the channel
    > PRIVMSG #anders :hello everyone!
    < :anders!anders@anders.com PRIVMSG #anders :hey there anders_lua!
    > PRIVMSG #anders :hi anders
    Hope this helps

    If you use mIRC you can also use /debug @foo to open a window that shows all IRC messages being sent/received

  33. Post #33
    SamuraiMush's Avatar
    April 2008
    4 Posts
    Anders2 posted:
    Here's a small IRC protocol guide:

    To connect to the server, port 6667:

    USER username . . :The Real Name (appears in whois)
    NICK yournick

    You should then get a PING somethingrandom, send PONG somethingrandom back

    Then you get stuff like

    :server.com 001 blahblah, when you get 001 it means you can JOIN channels

    use PRIVMSG target :message blah blah to send a message

    Code:
    < NOTICE AUTH :*** blah blah ignore this stuff
    > USER anders . . :Anders
    > NICK anders_lua
    < PING :123568
    > PONG :123568
    < lots of junk, ignore this
    < :server.com 001 <junk>
    > JOIN #anders
    < some junk about the channel
    > PRIVMSG #anders :hello everyone!
    < :anders!anders@anders.com PRIVMSG #anders :hey there anders_lua!
    > PRIVMSG #anders :hi anders
    Hope this helps

    If you use mIRC you can also use /debug @foo to open a window that shows all IRC messages being sent/received
    Yeah I had it going according to specification, it didn't work out because I had forgotten the \n dar

  34. Post #34
    Hexeh's Avatar
    August 2007
    74 Posts
    DarkSpider posted:
    Or use the udp version and send data between servers and run a 128 man server!
    Servers can't handle 64 players in GMod, nevermind 128.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Dumb Dumb x 1 (list)

  35. Post #35
    Gold Member
    DarkSpider's Avatar
    July 2006
    816 Posts
    Mine can. As long as nobody is shooting. You only get minor lag but not really that bad.

  36. Post #36
    Gold Member
    Spacetech's Avatar
    January 2006
    510 Posts
    Hexeh posted:
    Servers can't handle 64 players in GMod, nevermind 128.
    I was in one of his servers with 64players in it. It was fun.

  37. Post #37
    spbogie's Avatar
    June 2006
    14 Posts
    I have modified the Lua files to fix the problems with using the sub-modules (socket.http, socket.ftp, etc...).

    Required Changes:
    Code:
    moved socket.lua to /socket/socket.lua
    
    added socket.lua
        includes /socket/*.lua in necessary order
    
    changed /socket/mime.lua
        removed reqiure( "io" ) - unused, not available in gmod
    
    changed /socket/smtp.lua
        Line 33: DOMAIN = os.getenv("SERVER_NAME") or "localhost"
            to: DOMAIN = "localhost"
        os.getenv not available in gmod
    Calling require( "socket" ) will load all sub-modules as well.

    Fix is available at http://people.msoe.edu/~bogies/luasocket_fix.zip.
    Includes only modifications made, simply extract over existing install.

  38. Post #38

    August 2005
    51 Posts
    Some folks at Wiremod.com are playing with this, and it seems to be working!
    They've been transmitting Wire Values from one server to another!

    But for now were testing it out. So far so good!

    Keep up the great work!

  39. Post #39
    Gold Member
    MrPresident's Avatar
    August 2007
    97 Posts
    I got this working on my Garrysmod locally, but unfortunately my dedicated server host doesn't have the VS2008 files, so this doesn't work for me on my hosted server. I was going to re-create a gmod version of HLSW so that I could monitor prop spawns and other garrysmod specific things that aren't sent with the log normally.

    Does anyone know how I might go about getting this to work without my host installing the VS2008? Are there any lua files I can add to my garrysmod bin folder or anything?

    Also, I saw someone mention an older gm_socket earlier in this thread, but alas I could not find this anywhere.

    Thanks :)

  40. Post #40
    Anders1's Avatar
    September 2005
    82 Posts
    You don't need to install VS2008, you just need the latest .dll's. I think with any recent service pack you should already have them.