[QUOTE=Nikita;22510202]For some reason it still crashes... (Updated the code in my post)
For a server app that waits for datagrams, there should be exactly one Receive call in the buffer at any one time?[/QUOTE]
use [url=http://www.facepunch.com/showpost.php?p=22418056&postcount=102]My code[/url]
How may UDP packs per tick can be sent and received without any packet lost?
And can you add separate hooks for every Callback Type, it would be more useful and easier to use for people, who wants to replace the old lua socket in there addons.
Fore example connection:OnBind(ip,port) instant of SCKCALL_BIND in the Callback hook,
called by connection:Bind("", 37777) and returns what you bound.
Try it out.
Send like 1000 of these.
[lua]
local counter = 0
conn:Send(glon.encode({counter, CurTime()}), IP, PORT)
counter = counter + 1
[/lua]
And then receive them and check to see if the counter skipped, and check to see the latency of it.
[QUOTE=haza55;22533477]Try it out.
Send like 1000 of these.
[lua]
local counter = 0
conn:Send(glon.encode({counter, CurTime()}), IP, PORT)
counter = counter + 1
[/lua]
And then receive them and check to see if the counter skipped, and check to see the latency of it.[/QUOTE]
OK, I tested it (1 time) with a for loop around the sending function:
At a 255 chars long string, It can send 39 times/tick without Packet loss,
your example can be sent 400 times/tick, A 8-10 long string can be sen around 1000 times/tick.
The receiving of each test took about 1 second.
Edit: When I wrap the for loop in a think hook or in a time then I lost a lot of packs and the Chaos comes. :(
So there is a kind of speed limit, it's unlike the old Lua Socket, it didn't have a limit so it worked better.
You've done good work so far, but can you take look at this and fix it please?
maybe make a queue system? if the sended size a tick is more then 255 bytes then wait and send it next tick?
What else do you guys expect from UDP? Its not a reliable system.
But I'll have a look.
Yea, why not use TCP anyway? It's much better.
[QUOTE=ali3n92;22550238]Yea, why not use TCP anyway? It's much better.[/QUOTE]
For what I'm using I need UDP. :)
Edit:
[QUOTE=haza55;22546522]What else do you guys expect from UDP? Its not a reliable system.
But I'll have a look.[/QUOTE]
I only tested UDP, so far I know UDP can more. ;)
TCP uses much more networking, and its also more complex.
UDP is fast clean and is easy to use for fast delivery, tcp you have to handle and keep open a connection until the message got truw, else it doenst even get there :S
[QUOTE=bromvlieg;22559746]UDP is fast clean and is easy to use for fast delivery, tcp you have to handle and keep open a connection until the message got truw, else it doenst even get there :S[/QUOTE]
UDP packets aren't guaranteed to be received:
[quote=Wikipedia]UDP uses a simple transmission model without implicit hand-shaking dialogues for guaranteeing reliability, ordering, or data integrity. Thus, [b]UDP provides an unreliable service and datagrams may arrive out of order, appear duplicated, or go missing without notice.[/b] UDP assumes that error checking and correction is either not necessary or performed in the application, avoiding the overhead of such processing at the network interface level.[/quote]
-snip one page late-
UDP for small little things (eg cross server chats is fine). Anything a bit bigger will just cause it to fall out of place.
[QUOTE=Teddi Orange;22578203]UDP for small little things (eg cross server chats is fine). Anything a bit bigger will just cause it to fall out of place.[/QUOTE]
Im playing whit UDP and so far it works perfecly as my last TCP useage, i can send over adv dups, chats, player data whitout any packetloss so far (tested whit 50 adv dups 300-800kb):holy:
Seems to work without any crashes or problems now.
[QUOTE=bromvlieg;22582857]Im playing whit UDP and so far it works perfecly as my last TCP useage, i can send over adv dups, chats, player data whitout any packetloss so far (tested whit 50 adv dups 300-800kb):holy:[/QUOTE]
How long did it take to send and received the data?
[QUOTE=Grocel;22599785]How long did it take to send and received the data?[/QUOTE]
a 351 kb file takes 2 minutes and 17 seconds whit the settings i use.
But thats mainly becouse my internet is worse then shit. (30kb up sometimes even less, and 70-100 kb down wich is quite often at 20kb)
So i had a hard time tweeking the delay between each message and the message size.
in the end it was each 0.1 seconds send 20 letters, else it would send too fast for my internet to handle :0
I'm trying to write a little webserver with this, but I'm only getting a callback on the Bind and Listen. Firefox can connect to it, but because the callback is not called, it sits there forever waiting for data.
[lua]local socket = OOSock( IPPROTO_TCP )
socket:SetCallback( callback )
socket:Bind( "", 80 )
socket:Listen( 1 )
socket:Accept()[/lua]
What am I missing? Also, when I reload the map after restarting the server, no callbacks are called at all anymore.
Listen should happen in the bind callback.
Accept should happen in the listen callback,
Accept should happen again in the accept callback.
Well, this is my current code:
[lua]/*-------------------------------------------------------------------------------------------------------------------------
Serverside DataFlow initialization
-------------------------------------------------------------------------------------------------------------------------*/
if ( !OOSock ) then require( "oosocks" ) end
local dataflow = {}
function dataflow.Initialize()
dataflow.Socket = OOSock( IPPROTO_TCP )
dataflow.Socket:SetCallback( dataflow.Callback )
dataflow.Socket:Bind( "", 80 )
print( "[Dataflow] Initialized server socket." )
end
function dataflow.Callback( socket, call, id, err, data, peer, peerPort )
if ( err != SCKERR_OK ) then print( "[Dataflow] Oh dear, an error!" ) end
if ( call == SCKCALL_BIND and err == SCKERR_OK ) then
print( "[Dataflow] Succesfully bound!" )
socket:Listen( 1 )
elseif ( call == SCKCALL_LISTEN and err == SCKERR_OK ) then
print( "[Dataflow] Succesfully started listening!" )
sock:Accept()
else
print( "[Dataflow] Unknown callback:" )
print( socket, call, id, err, data, peer, peerPort )
end
end
dataflow.Initialize()[/lua]
The bound callback is called, but the listen callback is never called.
[QUOTE=Overv;22605859]Well, this is my current code: *CODE*
The bound callback is called, but the listen callback is never called.[/QUOTE]
I dont think that the socket is the same as the real one
Try printing it, you wil notice that the tablename keeps changeing, so its not the same socket each time
I needed to make an global of my socket and just use that one each time, instead useing the socket in the args
as yours is "dataflow.Socket", so try "dataflow.Socket instead" of "socket"
This is erroring if I connect to the socket (listens ok ,though) (gives nothing but a "attempt to call a userdata value" when I connect to the socket)
[LUA]
if ( !OOSock ) then require( "oosocks" ) end
if ( !OOSock ) then error"no oosocks module found" end
-- Useful (I hope) snippet for debugging
-- Bit lua magic and one could generalize this for any enum debugging
local SCKCALL=
[[SCKCALL_CONNECT
SCKCALL_LISTEN
SCKCALL_BIND
SCKCALL_ACCEPT
SCKCALL_REC_LINE
SCKCALL_REC_SIZE
SCKCALL_REC_DATAGRAM
SCKCALL_SEND]]
SCKCALL=string.Explode("\n",SCKCALL)
local Numbers={}
for k,v in pairs(SCKCALL) do
v=string.Trim(v)
Numbers[v]=_G[v]
if Numbers[v]==nil then ErrorNoHalt("Could not find "..tostring(v).."!\n") end
end
print("Loaded ",table.Count(Numbers)," SCKCALL_ enums")
function OOSocks_GetSCKCALL(num)
for name,enum in pairs(Numbers) do
if enum==num then
return name
end
end
end
local SCKERR=
[[SCKERR_OK
SCKERR_BAD
SCKERR_CONNECTION_RESET
SCKERR_NOT_CONNECTED
SCKERR_TIMED_OUT]]
SCKERR=string.Explode("\n",SCKERR)
local Numbers={}
for k,v in pairs(SCKERR) do
v=string.Trim(v)
Numbers[v]=_G[v]
if Numbers[v]==nil then ErrorNoHalt("Could not find "..tostring(v).."!\n") end
end
print("Loaded ",table.Count(Numbers)," SCKERR_ enums")
function OOSocks_GetSCKERR(num)
for name,enum in pairs(Numbers) do
if enum==num then
return name
end
end
end
-- Erroring code itself
print( "[Socket] Initializing..." )
Socket = OOSock( IPPROTO_TCP )
local port=6000
Socket:SetCallback(function( self, call, id, err, data, peer, peerPort )
Msg(" - ")
if ( call == SCKCALL_BIND and err == SCKERR_OK ) then
print( "[Socket] Succesfully bound!" )
self:Listen( port )
elseif ( call == SCKCALL_LISTEN and err == SCKERR_OK ) then
print( "[Socket] Succesfully started listening!" )
self:Accept()
--Socket:SetCallback(function() Msg"!!!" end) -- Still errors..
else
Msg( "[socket] Failed callback ")
print(self, OOSocks_GetSCKCALL(call), id, OOSocks_GetSCKERR(err), data, peer, peerPort )
end
end )
Socket:Bind( "", port )
[/LUA]
Output
[CODE]
] lua_Send_sv overvoo.lua
LuaDev_cl: Uploading ..
LuaDev_sv: Running script from Python¹³²º
Loaded 8 SCKCALL_ enums
Loaded 5 SCKERR_ enums
[Socket] Initializing...
- [Socket] Succesfully bound!
- [Socket] Succesfully started listening!
(all ok for now, now I connect)
attempt to call a userdata value
[/CODE]
[QUOTE=bromvlieg;22600329]a 351 kb file takes 2 minutes and 17 seconds whit the settings i use.
But thats mainly becouse my internet is worse then shit. (30kb up sometimes even less, and 70-100 kb down wich is quite often at 20kb)
So i had a hard time tweeking the delay between each message and the message size.
in the end it was each 0.1 seconds send 20 letters, else it would send too fast for my internet to handle :0[/QUOTE]
Usually the upload is about 10 times slower then the download, so you uploaded with about 3 kb/s.
You I have a stronger internet with ~600 kb/s download / ~60kb/s upload.
The UDP in the dll can handle (send and reserve with out pack loss) about 40 strings with each 256 bytes in a sec, so the max handle speed of it is about 10 kb/s, and I tested it on a loop-back connection, so there should not be any pack loss there.
To compare:
The UDP of previous socket module (gm_luasocket) could handle the data so fast as your internet with out any pack loss due to internal complications.
Looks like I need to write some Heavy Duty testing code that can be scaled up and down and record information.
Noob question here, where do I put dll modules? I've tried garrysmod/garrysmod and garrysmod/garrysmod/bin both fail to include
Edit: tried lua/modules like another website suggested, trying lua/includes/modules now. I think that will work.
[QUOTE=Grocel;22617854]Usually the upload is about 10 times slower then the download, so you uploaded with about 3 kb/s.
You I have a stronger internet with ~600 kb/s download / ~60kb/s upload.
The UDP in the dll can handle (send and reserve with out pack loss) about 40 strings with each 256 bytes in a sec, so the max handle speed of it is about 10 kb/s, and I tested it on a loop-back connection, so there should not be any pack loss there.
To compare:
The UDP of previous socket module (gm_luasocket) could handle the data so fast as your internet with out any pack loss due to internal complications.[/QUOTE]
Indeed, however when your useing this on a dedicated server in a datacenter, i dont think you need to worry about the packetloss as it sends em all, ive did some more testing, as so far i can put my server to spam each 0.03 seconds 500 letters to me, while i can only accept one of those packets in a second, wich resoutls in my internet to die.
Edit:
Il just quote myself from the WAYWO for the once that dint see my post there, Try testing your transver speed whit this. im intrested how fast you can upload/download files whit it :D
[QUOTE=bromvlieg;22600279]UDP socketing useing OOSocks
[media]http://youtube.com/watch?v=yYNah1FEdtk[/media]
Ingore the fact that the server im sending to is being crashed 3 times in a row
[/QUOTE]
[QUOTE=bromvlieg;22601471]Files:
The OOSocks lib thingy that i coded (supports passwored to secure thay have access): Pastebin
SV side of the file transver: Pastebin
CL side of the file transver: Pastebin
Im sure you guys can figure out how it works, that i dont need to write a massive post whit my horible grammar.
[/QUOTE]
[QUOTE=bromvlieg;22601471]Thats too easy.
Files:
The OOSocks lib thingy that i coded: [url=http://pastebin.com/aMhLKbAn]Pastebin[/url]
SV side of the file transver: [url=http://pastebin.com/dn444GpJ]Pastebin[/url]
CL side of the file transver: [url=http://pastebin.com/h0LYrt0P]Pastebin[/url]
Im sure you guys can figure out how it works, that i dont need to write a massive post whit my horible grammar.[/QUOTE]
It doesn't work, it doesn't matter what I do if get allways this error:
[Code]OOSocks: Error while sending "file_start=testfile.txt" to FileTranz, no such connection.[/Code]
I put it in a addon format:
[url]http://www.file-upload.net/download-2609944/sockettest.rar.html[/url]
Can you say me what I did wrong?
I tried to send to my self with the 127.0.0.1 Ip, I tried to sent to a friends server and I my friend tried to send to me, but it doesn't work.
[QUOTE=Grocel;22726972]It doesn't work, it doesn't matter what I do if get allways this error:
[Code]OOSocks: Error while sending "file_start=testfile.txt" to FileTranz, no such connection.[/Code]I put it in a addon format:
[URL]http://www.file-upload.net/download-2609944/sockettest.rar.html[/URL]
Can you say me what I did wrong?
I tried to send to my self with the 127.0.0.1 Ip, I tried to sent to a friends server and I my friend tried to send to me, but it doesn't work.[/QUOTE]
Sure you fil in the password good?
Sure you did the good ip?
As for the port also?
after you filed that in, press the reconnect button, and it should connect
after about a second open console, it should say like Connected to ****** whit the name *****
If not i would like to test it whit you.
[QUOTE=bromvlieg;22733019]Sure you fil in the password good?
Sure you did the good ip?
As for the port also?
after you filed that in, press the reconnect button, and it should connect
after about a second open console, it should say like Connected to ****** whit the name *****
If not i would like to test it whit you.[/QUOTE]
I entered no password and I did set a password (I think), I entered a port and the 127.0.0.1 (loopback ip) and the ip of my friend as I tested it with my friend, I tested it on a dedicated server and on a listen server, I also use the latest dll.
If gives me errors in the console and if I click reconnect after ip set up it say attempting to connect to ***** then I get an error with "no such connection".
[QUOTE=Grocel;22734772]I entered no password and I did set a password (I think), I entered a port and the 127.0.0.1 (loopback ip) and the ip of my friend as I tested it with my friend, I tested it on a dedicated server and on a listen server, I also use the latest dll.
If gives me errors in the console and if I click reconnect after ip set up it say attempting to connect to ***** then I get an error with "no such connection".[/QUOTE]
I made it work so that you must connect to both, so that when some one connected to you, you cant steal hiz filez unles you connect to him whit his pass also.
You need to fill in the pass. default it is "Filez" so, you need to connect to him, AND he needs to connect to you. Anyway, im working on it some more to remove the need to setting the anti packet loss settings...
This module seems to crash dedicated servers (both win and nix) when there are active sockets during changelevel.
On listenservers everything is OK.
Example code used:
[url]http://pastebin.com/zESB2w3a[/url]
(server in code will refuse connecions - generally it does accept and send(receive()) using plain lua with luasocket)
Sorry, you need to Log In to post a reply to this thread.