Help I need a tip.
#1
Lightbulb 
Hey guys,

I am doing my custom networking for my engine, so I need a little help. I'm using UDP socket, but as you know ( maybe ): "udp sends a packet and you'll never know - will it reach the destination or not."

So I am trying to make some kinda of "packet data check".
Pseudocode:
I got the struct called 'svpackets', this struct contains "char header[4];", "int clientIndex"; and 'bool clientGotMessage;'

So when the server sends a message to the client, it also fills the struct like:
Code:
svpackets[i].header[0] = CLIENT_MESSAGE_HEADER; // using rand to prevent message bothering svpackets[i].header[1] = 0x3f * ( _sv.time * rand() % 0x2f + 0x4f ); svpackets[i].header[2] ... etc svpackets[i].clientgotmessage = false; // not yet svpackets[i].clientIndex = client.Number; // parameter net_sendpacket(my data blablabla with svpackets.header); ++i; if(i > 30) i = 0; .. etc

Server runs loop, which also checks every client with svpacket, if svpacket.clientgotmessage equals TRUE, so just 'continue;'; If svpacket.clientgotmessage = false; so run timer for ~10 seconds and kick the client ( just because no packets for a long time ).

Soo, when client got the message from a server with 'CLIENT_MESSAGE_HEADER' header, it sends THE SAME header, but only changes the 'header[0]' to another value, so server will know that it is "return message", where it will set "clientGotMessage" to true.
The same method I've used for a clientsystem;

Since I am working with networking not for so long time, I am not sure at all.
It works great now, but as I've said before, I am not sure that it's good system at all,
is there any tip to make it better?

Here's what I got now:
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#2
Wow now you we ask for help ) unfortunately I don't know
Reply

#3
What about using TCP?
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#4
(02-01-2014, 19:24)Ich1994 Wrote: What about using TCP?

I don't want to use it because there are several reasons.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#5
(02-01-2014, 23:11)SailorMoon Wrote:
(02-01-2014, 19:24)Ich1994 Wrote: What about using TCP?

I don't want to use it because there are several reasons.

Then list them doe....
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#6
(02-02-2014, 00:37)Ich1994 Wrote:
(02-01-2014, 23:11)SailorMoon Wrote:
(02-01-2014, 19:24)Ich1994 Wrote: What about using TCP?

I don't want to use it because there are several reasons.

Then list them doe....

Well, this is not that important.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#7
(02-02-2014, 13:31)SailorMoon Wrote:
(02-02-2014, 00:37)Ich1994 Wrote:
(02-01-2014, 23:11)SailorMoon Wrote:
(02-01-2014, 19:24)Ich1994 Wrote: What about using TCP?

I don't want to use it because there are several reasons.

Then list them doe....

Well, this is not that important.

Nice to know...
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#8
Hello,

When i was creating a multiplayer game with XNA, i was using "lidgren network gen3" (http://code.google.com/p/lidgren-network-gen3/) for the network part, it was very easy to use and worked very well, maybe you can take a look at the source to get some good points from it. If i'm not wrong, it uses a combination of UDP and TCP.

A bit of info:
There are five delivery methods available:

Unreliable This is just UDP. Messages can be lost or received more than once. Messages may not be received in the same order as they were sent.
UnreliableSequenced Using this delivery method messages can still be lost; but you're protected against duplicated messages. If a message arrives late; that is, if a message sent after this one has already been received - it will be dropped. This means you will never receive "older" data than what you already have received.
ReliableUnordered This delivery method ensures that every message sent will be eventually received. It does not however guarantee what order they will be received in; late messages may be delivered before newer ones.
ReliableSequenced This delivery method is similar to UnreliableSequenced; except that it guarantees that SOME messages will be received - if you only send one message - it will be received. If you sent two messages quickly, and they get reordered in transit, only the newest message will be received - but at least ONE of them will be received.
ReliableOrdered This delivery method guarantees that messages will always be received in the exact order they were sent.

Hope this help.
Reply

#9
(02-05-2014, 19:50)narkos Wrote: Hello,

When i was creating a multiplayer game with XNA, i was using "lidgren network gen3" (http://code.google.com/p/lidgren-network-gen3/) for the network part, it was very easy to use and worked very well, maybe you can take a look at the source to get some good points from it. If i'm not wrong, it uses a combination of UDP and TCP.

A bit of info:
There are five delivery methods available:

Unreliable This is just UDP. Messages can be lost or received more than once. Messages may not be received in the same order as they were sent.
UnreliableSequenced Using this delivery method messages can still be lost; but you're protected against duplicated messages. If a message arrives late; that is, if a message sent after this one has already been received - it will be dropped. This means you will never receive "older" data than what you already have received.
ReliableUnordered This delivery method ensures that every message sent will be eventually received. It does not however guarantee what order they will be received in; late messages may be delivered before newer ones.
ReliableSequenced This delivery method is similar to UnreliableSequenced; except that it guarantees that SOME messages will be received - if you only send one message - it will be received. If you sent two messages quickly, and they get reordered in transit, only the newest message will be received - but at least ONE of them will be received.
ReliableOrdered This delivery method guarantees that messages will always be received in the exact order they were sent.

Hope this help.

That's useful for me, thanks. Also I don't want to use 3rd party libs/apps, just because I want to earn some experience. Nyan Cat
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.