Forum
CS2D General [RELEASE] Custom CS2D Server a0.1This is the source code and you have to compile it. Don't ask here until you can tell me exactly errors. And just btw: This is a alpha version. The version for noobs will come out when the server reaches the beta status.
http://www.mediafire.com/?i70yv7q058d9jj3
edited 2×, last 01.11.10 04:21:46 am
With a working lag compensation!
FlooD has written
is it just me or is server.cfg useless...
is it? I only took a look at the interface and it seems that if you don't specify a value for a certain field, it defaults to the values that were coded into the server.
idk whether he did this accidentally or not
question:
1
if (FD_ISSET(readsocket, &descriptor))
im very confused o.O
FlooD has written
btw jermuk's code for main.c screws up the fps cuz the sleep function is inside an else loop
idk whether he did this accidentally or not
question:
that means if a packet is received?
idk whether he did this accidentally or not
question:
1
if (FD_ISSET(readsocket, &descriptor))
1) Fixed with new version
2) yes
@All:
New version out! Added now leegoa's rcon_pw and my non-working drop.
maybe that's why it lags when i set fps to 50 and start jamming keys in cs2d.
if i am wrong then just ignore what i write below
my idea:
current loop:
(stuff repeated every frame, including updatebuffer)
if (received packet)
....(packet stuff)
(sleep)
// one loop corresponds to one frame
loop for multiple packets per frame:
if (received packet)
....(packet stuff)
else
....(stuff repeated every frame)
....(sleep)
// one cycle of the else statement corresponds to one frame
i tried it and the else control does get reached... i know because of !fps
FlooD has written
o.O
i tried it and the else control does get reached... i know because of !fps
i tried it and the else control does get reached... i know because of !fps
are we actually using a nonblocking server?
Meh, I guess that makes sense seeing as we're handling multiple connections at the same time.
my guess: delaying the processing of packets???
And I think we are using a non-blocking server (timeout is 0 (zero; not NULL)).
@DannyDeth:
If you want to help us, just contact me.
Jermuk has written
Well, we can use threads, but with them we have to rewrite many parts.
And I think we are using a non-blocking server (timeout is 0 (zero; not NULL)).
And I think we are using a non-blocking server (timeout is 0 (zero; not NULL)).
We don't necessarily need to write a dispatch in order to achieve concurrency, a proven technique to achieve concurrency within small timeouts can be written with the select() on the socket's IO descriptors (which apparently we're already using, God I need to read the source code more often)
http://www.codeproject.com/KB/IP/ScalableClientServer.aspx#premain3
At a higher level:
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Socket server fd_set {read, write, error} = select(server.fileDescriptor) if server in read: 	// Handles incoming packets 	// Timeout else if server in write: 	// Send out packets else if error != 0: 	// Handle exceptions - Bad stream, send request for reconfirmation
Note that select does not block, so we can add in state updates before or after the selector.
Also, it's possible to implement a queue in order to process outgoing items. This way we can make sure that a socket is ready for writing as well as keeping track of corrupted packets (AKA, we requeue items that have not had a confirmation packet sent back to the server yet), this might be a necessity when we have live servers with lots of people playing. If I remember correctly from a profiler on the pre0104 server, we experienced less than 1% packet loss with fewer than 6 people while as high as 7% packet loss with over 12 people, the latter is very significant if we don't resend corrupted data.
Yeah, I already thought about that. But at the beginning I was bored from this low level stuff and I wanted to start the server. Then I forgot it. And to tell the truth: My experience is not enough for such complicated socket handling (thats my first project with sockets). But if you want to implement it, i won't stop you
And btw the link is C++