• OOSocks
    279 replies, posted
One more bug, once youve closed an socket (or the other side closed it) it recieves one final message including some random signs and the longest text again, wich i had earlijker (Its fixed in the normal messages now :D)
[QUOTE=ali3n92;21809594]SetTimeout doesn't seem to work for Connect, my server freezes for about 20 seconds instead of 300 miliseconds.[/QUOTE] I can second this, the timeout isn't working on my client socket for me.
Does this module fully support UDP, because at UDP usually you send packs without connecting before?
[QUOTE=Grocel;21854751]Does this module fully support UDP, because at UDP usually you send packs without connecting before?[/QUOTE] Currently rewriting the whole socket system to be threaded and I have included full UDP and TCP support in the design.
[QUOTE=haza55;21855301]threaded[/QUOTE] Yay!
Yay, no more timeouts. :dance:
I'd love it to be threaded, Nice work.
You should rewrite your P2PChat and use it as an example using all of the functions and features of this module.
Let him finish the module first ;)
Well I've finished the code, now for some intense debugging. Have to make sure everything is performing as designed. I'll throw the code up if people want to make suggestions. [url]http://gmod-haza.googlecode.com/svn/trunk/gm_oosocks/src/include/ThreadedSocket.h[/url]
Ah, callbacks :D.
Callbacks is the only way.
[QUOTE=haza55;21892967]Callbacks is the only way.[/QUOTE] Is it possible that you can post example usage :)?
[QUOTE=Eusion;21892990]Is it possible that you can post example usage :)?[/QUOTE] I haven't uploaded the dll yet. But here is how it will work. [lua] function SockCallback(socket, callType, callId, error, data, peer) if(callType == SCKCALL_CONNECT && error == SCKERR_OK) then socket:ReceiveLine() end if(callType == SCKCALL_REC_LINE && error == SCKERR_OK) then Msg("Got " .. data .. " from " .. peer) end end local sock = OOSock(IPPROTO_TCP); sock:SetCallback(SockCallback); sock:Connect("google.com", 80); [/lua] I'm hoping to add nicer callback stuff, but that would be done in pure lua. Whereby each call is an object and you can give it it's own callback stuff.
[QUOTE=haza55;21893147]I haven't uploaded the dll yet. But here is how it will work. [lua] function SockCallback(socket, callType, callId, error, data, peer) if(callType == SCKCALL_CONNECT && error == SCKERR_OK) then socket:ReceiveLine() end if(callType == SCKCALL_REC_LINE && error == SCKERR_OK) then Msg("Got " .. data .. " from " .. peer) end end local sock = OOSock(IPPROTO_TCP); sock:SetCallback(SockCallback); sock:Connect("google.com", 80); [/lua] I'm hoping to add nicer callback stuff, but that would be done in pure lua. Whereby each call is an object and you can give it it's own callback stuff.[/QUOTE] Brilliant, thanks.
At last! Nice work haza. :bow:
I have a suggestion i dont know if this is possible. But could you create a hook for Receive and ReceiveLine ?
[QUOTE=ColdFusion;21901561]I have a suggestion i dont know if this is possible. But could you create a hook for Receive and ReceiveLine ?[/QUOTE] Dont worry, once he finished his module, i wil release my lua side module of it, wich includes all hooks for every thing needed. Howerver im quite sad about the multi threating, since it would make it hard to make hooks of it.
Connecting and sending seems to be fine but i don't seem to be able to keep a connection open [lua]require( "oosocks" ) sock = OOSock(IPPROTO_TCP) sock:SetTimeout(5) sock:Bind(9091) hook.Add("Think", "TcpThink", function() sock:Listen(5) if(sock:Accept())then ErrorNoHalt("Accepted\n") sock:SendLine("Hello") ErrorNoHalt(sock:GetLastError()) end local data,ip = sock:ReceiveLine() if(data and data != "")then ErrorNoHalt("data!"..data.."\n") end if(sock:GetLastError() > 0)then ErrorNoHalt(sock:GetLastError()) end end)[/lua] It will Accept the socket but will disconnect the client straight away I am testing it with this [url]http://sourceforge.net/projects/sockettest/[/url]
Anyone tried UDP? I can't seem to get it working. Any examples?
[QUOTE=Python1320;21959905]Anyone tried UDP? I can't seem to get it working. Any examples?[/QUOTE] UDP is different then TCP, UDP don't need to connect, it sends data as packs and TCP need to connect before you can send data.
UDP will be fully supported in the threaded version.
[QUOTE=Grocel;21961485]UDP is different then TCP, UDP don't need to connect, it sends data as packs and TCP need to connect before you can send data.[/QUOTE] Believe me, I know (Went through CCNA Semesters 1 to 3). I just can't get UDP to work with OOSocks. Better wait for haza's threaded version. Any chance of that dns/rnds resolver, by the way?
I don't know shit about sockets and how they work, but can this be used to get around the google translate symbol problem? Or is that lua related?
[QUOTE=CapsAdmin;21965609]I don't know shit about sockets and how they work, but can this be used to get around the google translate symbol problem? Or is that lua related?[/QUOTE] lua related. (but haza wanted to make some extended string whatever... )
[QUOTE=Python1320;21962008]Believe me, I know (Went through CCNA Semesters 1 to 3). I just can't get UDP to work with OOSocks. Better wait for haza's threaded version. Any chance of that dns/rnds resolver, by the way?[/QUOTE] All host names passed to oosocks will be resolved. On another note, Why would you want reverse dns? I'm not saying I won't implement it, just, if theres not a good reason why bother.
[QUOTE=haza55;21978234]On another note, Why would you want reverse dns? I'm not saying I won't implement it, just, if theres not a good reason why bother.[/QUOTE] Reverse user ip addresses. ISP ban. Country code. Most IRCds do it too. If it's too much of a hassle then never mind.
[QUOTE=Python1320;21980201]Reverse user ip addresses. ISP ban. Country code. Most IRCds do it too. If it's too much of a hassle then never mind.[/QUOTE] I can do it in windows, but until I know how to do it in linux/darwin, I won't bother.
Bumbzor, Any chance we can get the new version of the module, wich suports UDP?
I'm anticipating the arrival of the threaded version :P.
Sorry, you need to Log In to post a reply to this thread.