im using a 32 bit system, and long is also called long long or 64bit integer, with range from:
Code: Select all
signed long long LLONG_MIN -9223372036854775807
LLONG_MAX 9223372036854775807
Greetings
Scarabol
Code: Select all
signed long long LLONG_MIN -9223372036854775807
LLONG_MAX 9223372036854775807
Code: Select all
//! Operator extension to IrrNetLite
SOutPacket& operator << (SOutPacket& lhs, const SOutPacket& rhs) {
const c8* Data = const_cast<SOutPacket&>(rhs).getData();
size_t Size = const_cast<SOutPacket&>(rhs).getSize();
for (size_t i=0; i<Size; ++i)
lhs << Data[i];
return lhs;
}
Code: Select all
Object* CGameManager::makeObject(SInPacket& P)
{
SInPacket Peek(P);
ObjectType Type;
Peek >> Type;
switch (Type) {
// Continue use of `P'
Since I abstracted the Enet interface away, theres really no way of doing it without exposing the interface yourself and recompiling IrrNetLite. Then you can probably adjust a relevant setting directly through the Enet host, as timeouts are handled by it.Is it possible to set the timeout for server, when he sets the client as disconnected?
Yes that's a good idea for now.Scarabol, use this meanwhile:
I'm not sure why you need to do this, once you read the packet type header you can store it somewhere and do whatever you want with it, it sounds like a bad design decision to have to peek at it. But I suppose some kind of Peeking functionality is expected, so I'll add that to the TO-DO list. I should add getPos, maybe setPos too, will have to think about the repercussions of that one.I thought I could design my code in a way that I wouldn't need any further modifications of IrrNetLite, but it was impossible. I had to write a little workaround to peek for the next byte without modifying the read position (no get/setPos for SInPacket):
You're right, this is important. Needs a getSize().Another thing is, that debugging of an incoming packet is hard, because I can't get the byte size of the incoming packet, as there is no getSize() function for SInPacket. So I can only guess how long the char array returned by getData() could possibly be.
Good point maybe it would be a good idea to send the character size along with the string (Only an extra byte) and use that when decoding.@BlindSide: After reading this, I'm wondering if it is save to send stringw between Linux and Windows machines.
Code: Select all
net::SInPacket packet;
net::SOutPacket packet; //other data types create a debug error here :-(
Well, maybe you could implement it somehow in a const way, so that it won't change the packet. I'll tell you why I probably (I'm not 100% sure though) need that.BlindSide wrote:I'm not sure why you need to do this, once you read the packet type header you can store it somewhere and do whatever you want with it, it sounds like a bad design decision to have to peek at it. But I suppose some kind of Peeking functionality is expected, so I'll add that to the TO-DO list. I should add getPos, maybe setPos too, will have to think about the repercussions of that one.
Two possibilities. At first I thought about sending a byte which contains several flags for special behaviour of irrnet. But then I thought that maybe other machines could use completely different sizes for wchar_t as well. I'm not sure yet. But sending it once at the beginning of the packet is definitively the best way respectively.BlindSide wrote:Good point maybe it would be a good idea to send the character size along with the string (Only an extra byte) and use that when decoding
Why would someone want to do that??? And no, it's not possible. There's no default constructor for class SInPacket anyway...Scarabol wrote:why is this possible?Code: Select all
net::SInPacket packet; net::SOutPacket packet; //other data types create a debug error here :-(
Code: Select all
<< event.peer->address.port << std::endl;
Code: Select all
std::cout << str.c_str();
Problem confirmed.BlindSide wrote:Good point maybe it would be a good idea to send the character size along with the string (Only an extra byte) and use that when decoding.@BlindSide: After reading this, I'm wondering if it is save to send stringw between Linux and Windows machines.
Yes, it is possible. What I recommend you do is combine these 2 packets into a single packet. Then you would have all that information in the intended order. Is there a reason that is not practical? Enet can take any packet size and split it up into smaller packets then join it again, so packet size is not usually an issue unless it is so big that it would eat performance (Anything under 10kb should be fine).1) Is it possible for packets to be received in an order other than they are sent? My host sends a game description out to clients whenever they connect, and I've got a problem where the client will receive packets pertaining to a game they haven't received details about yet. So it would seem that the packets sent using the OnConnect callback are being received after packets sent at other times. Is this possible? I would have thought that OnConnect() would be called by the host before a new user started receiving packets, or is this not the case?
2) Is it foolish to have a system that relies integrally on every packet being delivered successfully, or should I take into account the possible that data may be lost?
So apparently Enet does guarantee sequenced delivery. We may be running into this issue: http://lists.cubik.org/pipermail/enet-d ... 00746.htmlENet provides sequencing for all packets by assigning to each sent packet a sequence number that is incremented as packets are sent. ENet guarentees that no packet with a higher sequence number will be delivered before a packet with a lower sequence number, thus ensuring packets are delivered exactly in the order they are sent.
For unreliable packets, ENet will simply discard the lower sequence number packet if a packet with a higher sequence number has already been delivered. This allows the packets to be dispatched immediately as they arrive, and reduce latency of unreliable packets to an absolute minimum. For reliable packets, if a higher sequence number packet arrives, but the preceding packets in the sequence have not yet arrived, ENet will stall delivery of the higher sequence number packets until its predecessors have arrived.
You already corrected it. And here are the flags :Now Enet does technically provide a reliable layer similar to TCP over UDP but packets may still be dropped. They are also not guaranteed to be in order.
By the way. TCP is not bad at all. I dont understand why people try to implements a own TCP over the lightwight UDP. Do you really think that using a racingcar as a base for a familycar is a good idea? Of course the original racingcar is faster but with a hanger for the package it is not really fast anymore, is it?/** packet must be received by the target peer and resend attempts should be
* made until the packet is delivered */
ENET_PACKET_FLAG_RELIABLE = (1 << 0),
/** packet will not be sequenced with other packets
* not supported for reliable packets
*/
ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1),
/** packet will not allocate data, and user must supply it instead */
ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2)