// Server
sf::Packet packet = bleh;
bleh << variables;
bleh << positions; // Loading the packet up with stuff..
ENetPacket * packet = enet_packet_create (bleh.getData(), bleh.getDataSize() + 1, ENET_PACKET_FLAG_RELIABLE);
enet_peer_send (peer, 0, packet);
// Client
sf::Packet packet;
packet.append(event.packet->data, event.packet->dataLength);
Don't send/receive sf::Packet with ENet. sf::Packet has its own internal protocol, which works well with SFML sockets, but won't be understood by other libraries.I really hope you're misunderstanding how I'm doing this. I really REALLY want to use sf::Packet to send stuff because it's easy to pack and unload variables. I plan on converting the packet into raw bytes so that sending the raw data won't interfere with anything. Can I do it this way? If not, how do you recommend I send data? If I send it as a string, I don't want to bother converting a string to an integer for position stuff.
I heard that sending packets in bytes is fasterWhat do you mean by this? All data in a computer is already "in bytes", regardless of what C++ abstraction you're using to manipulate it.
I'm using the enet (http://enet.bespin.org/) network library to make my game utilize both TCP and UDP.The site explicitly states that Enet is a UDP networking library. For TCP you will have to use something else.
If you only need to serialize standard C++ scalar types then std::stringstream should be fine. That class' interface is exactly what you appear to want sf::Packet's to be.Why std::stringstream? I would serialize data over network as binary data and not text, otherwise you're quickly wasting a lot of bandwidth.
"converting to bytes" sounds like you want to do serialization. sf::Packet has absolutely nothing to do with serialization.
If you'd want to use sf::Packet with something else than sfml-network, you'd have to implement the sf::Packet protocol yourself, which is not recommended, since that protocol is an internal detail, which could change any time.Not necessarily. As far as I've understood Honorabl3, he wants to use sf::Packet because it provides a conversion between formatted data (integers, double, bool, etc) and a byte array. In that way, sf::Packet does provide some kind of serialization, it just does not guarantee anything about the internal format or its stability over different SFML versions. Those limitations, however, are not an inherent obstacle as long as you're aware of them.
My bad, I don't need TCP. I'm using UDP because it functions like a TCP connection. It is faster then a TCP connection, and saves a client or w/e onto a .peer class object so that when a UDP connection is received it keeps the connection running.I'm using the enet (http://enet.bespin.org/) network library to make my game utilize both TCP and UDP.The site explicitly states that Enet is a UDP networking library. For TCP you will have to use something else.
Is there a reason why you don't use SFML, do you need certain features?
Apparently you need to re-read my post. That's exactly what I wrote.Your post doesn't mention converting binary data to sf::Packet?
My bad, I don't need TCP. I'm using UDP because it functions like a TCP connection. It is faster then a TCP connection, and saves a client or w/e onto a .peer class object so that when a UDP connection is received it keeps the connection running.I'm using the enet (http://enet.bespin.org/) network library to make my game utilize both TCP and UDP.The site explicitly states that Enet is a UDP networking library. For TCP you will have to use something else.
Is there a reason why you don't use SFML, do you need certain features?
It did mention getData(), getSize() and append(), which are what you use for that.Apparently you need to re-read my post. That's exactly what I wrote.Your post doesn't mention converting binary data to sf::Packet?
UDP and TCP do not function similarly at all, even if most networking libraries give similar APIs for them. You might want to read a bit more about what they actually are.
My bad, I don't need TCP. I'm using enet because it functions like a TCP connection. It is faster then a TCP connection, and saves a client or w/e onto a .peer class object so that when a UDP connection is received it keeps the connection running.
But that aside, his original question was why are you trying to use both SFML and ENet for your networking? Specifically, what feature is SFML lacking that ENet has? SFML supports UDP too.I'm using SFML's sf::Packet class because it's very easy to load and unload variables. enet would never send a sf::Packet, it would only send some binary data (which was created from the sf::Packet). Enet allows a client session instead of one simple UDP packet.
Stop using full quotes!!! Only quote relevant bits or don't quote at all if the context is obvious!!! >:(Haha I was going to remove some of the quotes, but I had food cooking in the kitchen. I was thinking "No one will complain about it this last time."