• OOSocks
    279 replies, posted
Let's hope it does...
It should, but when is the question :D
Today, I've finally finished a huge MySQL transition, So I have time for this.
[QUOTE=haza55;22208889]Today, I've finally finished a huge MySQL transition, So I have time for this.[/QUOTE] Great! Hope it goes ok :). I need it to replace luasocket desperately :P.
Well I've finished it, and it compiles on Win32 and its on SVN. Now I just need to write documentation for it.
[QUOTE=haza55;22211409]Well I've finished it, and it compiles on Win32 and its on SVN. Now I just need to write documentation for it.[/QUOTE] At long last, the awaited legendary oosocks is done ^^ Time to give this baby a test drive... Once the documentation is released.
FYI, I did update the first post with documentation :P
You appear to have forgotten Close()
[QUOTE=TechedRonan;22226173]You appear to have forgotten Close()[/QUOTE] = nil
Didn't mean documentation wise. How am I supposed to close a socket? Just stop listening to it or stop accepting clients?
[QUOTE=TechedRonan;22226374]Didn't mean documentation wise. How am I supposed to close a socket? Just stop listening to it or stop accepting clients?[/QUOTE] Just set the object to nil. That will close the socket and delete it. I do not see any need for a close function explicitly. Because essentially its saying, I don't want the socket anymore.
[QUOTE=haza55;22226403]Just set the object to nil. That will close the socket and delete it. I do not see any need for a close function explicitly. Because essentially its saying, I don't want the socket anymore.[/QUOTE] Ah, alright. May want to add that to the documentation. I'm a bit too used to low(ish) level socket programming, I'd usually close a bound socket before discarding it, otherwise the socket would remain busy.
[QUOTE=TechedRonan;22226664]Ah, alright. May want to add that to the documentation. I'm a bit too used to low(ish) level socket programming, I'd usually close a bound socket before discarding it, otherwise the socket would remain busy.[/QUOTE] Just think, "OOSocks does all the hard work for me, just forget about it."
Hm... I can't seem to get this to work. Every time I try to connect to a host, my game crashes a couple of seconds later. The example from the first post doesn't work for me neither (By the way, there's an "and" missing in line 12). I tried it with a clean gmod installation, but that didn't help.
[QUOTE=Silverlan;22228986]Hm... I can't seem to get this to work. Every time I try to connect to a host, my game crashes a couple of seconds later. The example from the first post doesn't work for me neither (By the way, there's an "and" missing in line 12). I tried it with a clean gmod installation, but that didn't help.[/QUOTE] It works fine for me, strange.
Updated the example code in OP. And it works fine for me.
Updated DLL. Fixed crash when a socket is deleted inside a callback. Corrected the spelling of SCKERR_CONNECTION_RESET. Edit: Updated linux binary.
Is the a way to get the origin (ip and port), the transfer speed and ping of the gotten data in a callback?
[QUOTE=haza55;22230784]Updated the example code in OP. And it works fine for me.[/QUOTE] Hm... yeah, nevermind that. I'm not quite sure why, but it seems to work now. Great work by the way!
All I can say, thanks! I had to recompile with no msvc deps so I could run it though, Worked great with your testing script after that!
[QUOTE=Python1320;22238750]All I can say, thanks! I had to recompile with no msvc deps so I could run it though, Worked great with your testing script after that![/QUOTE] If you want, I can build several Win32 versions. [editline]01:06AM[/editline] [QUOTE=Grocel;22237553]Is the a way to get the origin (ip and port), the transfer speed and ping of the gotten data in a callback?[/QUOTE] the peer argument in the callback should contain the origin ip : port. Speed and Ping is up to you to calculate.
I've been trying for the past seven hours to get a connection to work at all, and nothing... How does one go about listening for data with this?
[QUOTE=Whitewater;22253802]I've been trying for the past seven hours to get a connection to work at all, and nothing... How does one go about listening for data with this?[/QUOTE] Post your code, we can't read your mind...
[QUOTE=haza55;22246351]the peer argument in the callback should contain the origin ip : port. Speed and Ping is up to you to calculate.[/QUOTE] Ah, Thanks, that helped me. And does UDP support port binding, because you need port binding in a UDP transfer, I think?
[QUOTE=The-Stone;22253891]Post your code, we can't read your mind...[/QUOTE] I've tried many things, the latest incarnation is [lua]local sock = OOSock( IPPROTO_TCP ) sock:SetCallback( function( socket, cType, cID, err, data, peer ) sock:Listen( 21337 ) if( cType == SCKCALL_CONNECT && err = SCKERR_OK ) then sock:Accept() socket:SendLine( "Test" ) socket:ReceiveLine() end if( cType == SCKCALL_REC_LINE && err = SCKERR_OK ) then if( data && data != "" ) then ErrorNoHalt( "Received \"" .. data .. "\"\n" ) end end end )[/lua]
[lua]local sock = OOSock( IPPROTO_TCP ) sock:SetCallback( function( socket, cType, cID, err, data, peer ) if( cType == SCKCALL_LISTEN && err = SCKERR_OK ) then print("Listening...") end if( cType == SCKCALL_ACCEPT && err = SCKERR_OK ) then socket:SendLine( "Test" ) -- This will run a SCKCALL_SEND callback when completed. socket:ReceiveLine() -- This will run a SCKCALL_REC_LINE when read upto a \n character. -- Get ready for another socket sock:Accept() end if( cType == SCKCALL_REC_LINE && err = SCKERR_OK ) then if( data && data != "" ) then print( "Received \"" .. data .. "\"" ) end end end ) sock:Listen( 21337 ) -- This will run a SCKCALL_LISTEN callback when completed sock:Accept() -- This will run a SCKCALL_ACCEPT callback when a client is connecting. [/lua]
[QUOTE=haza55;22259811][lua]local sock = OOSock( IPPROTO_TCP ) sock:SetCallback( function( socket, cType, cID, err, data, peer ) if( cType == SCKCALL_LISTEN && err = SCKERR_OK ) then print("Listening...") end if( cType == SCKCALL_ACCEPT && err = SCKERR_OK ) then socket:SendLine( "Test" ) -- This will run a SCKCALL_SEND callback when completed. socket:ReceiveLine() -- This will run a SCKCALL_REC_LINE when read upto a \n character. -- Get ready for another socket sock:Accept() end if( cType == SCKCALL_REC_LINE && err = SCKERR_OK ) then if( data && data != "" ) then print( "Received \"" .. data .. "\"" ) end end end ) sock:Listen( 21337 ) -- This will run a SCKCALL_LISTEN callback when completed sock:Accept() -- This will run a SCKCALL_ACCEPT callback when a client is connecting. [/lua][/QUOTE] Thank you very much.
Can't seem to get UDP to work. Any example on that?
There are so many things wrong with this. Listening as a server doesn't work and the code 2 and 3 posts above me is wrong in a number of ways, not the least of which there's an assignment err = SCKERR_OK when it should be a comparison, the server is created without binding to ip, port and Listen is used incorrectly to specify port when Listen functions in sockets take an int argument of the backlog, or number of connections possible at once. I have done everything I possibly can to receive data and without being able to set a Timeout there is no time to receive any data and I end up with a SCKCALL_REC_LINE with null data. There is also nothing provided like the original luasockets module had to get ip/hostname from the opposite data thus any server NAT'd must provide it's IP in the sock:Bind call which doesn't allow code to be used across multiple servers as GetConVarString("ip") on a NAT'd server produces localhost and setting the srcds startup -ip to the NAT IP or WAN IP will produce their own errors. Why can't someone just recreate the luasockets module with the updated garry's mod? It worked perfectly until all of these shitty updates and now there is no fully functioning socket library.
I have corrected some mistakes in the documentation and have also updated the Win32 bins to take ip/port as arguments in Send and SendLine. I'm sorry for any mistakes, I kinda have a lot of work to do. There is no timeout needed, as the thread will not return a callback unless data has been collected or the socket has somehow died. Regarding the original luasockets module. It was not salvageable with the recent updates. If you want to go make one, go right ahead. But most developers want a non blocking threaded library(so do I), so thats what I made.
Sorry, you need to Log In to post a reply to this thread.