Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - FleshyOverlord

Pages: [1]
Network / Blocking and locking the UDP receive function
« on: January 28, 2020, 12:00:40 am »
Background: My program has two threads, the UDP receive function and the main game logic thread.

Is it safe to set a UDP socket to blocking and not lock the UDP receive thread when the socket.receive()function is called? I am worried that if I call a socket.send(packet, ip, port)function when the UDP socket is receiving it will interfere with socket. I was worried this is what might have been causing my program to lock up.

System / Non-Locked threads and Locked Threads
« on: January 26, 2020, 04:22:36 am »
If a non-locked thread tries to access data inside of a locked thread, will it be blocked from doing so?

Network / Should you use one UDP Socket for sending and receiving?
« on: January 17, 2020, 04:52:56 am »
Hello, I have a general question pertaining to SFML's networking. I read in one post that one UDP socket should not be used for both sending and receiving (I might have interpreted this incorrectly: https://en.sfml-dev.org/forums/index.php?topic=22917.0 4th post by Laurent). Is this true, or is it a good idea to stick to using one UDP socket for sending and receiving in SFML's architecture?

Network / Using sf::Lock on UDP sockets
« on: January 16, 2020, 04:50:01 am »
Hello, I am working on a tank game and am trying to use both TCP and UDP. So far the TCP is working however I am having difficulties getting UDP to work do to some confusion about mutex. Is it safe to use sf::Lock before calling receive on a blocking UDP socket, or will this stall the program?

                sf::Packet* uPack = new sf::Packet();
                sf::IpAddress rcvAddr;
                short unsigned int rcvPort;
                PacketCont* packCont = new PacketCont();
                sf::Lock lock(sManager->mutex);//this is the line I am worried about
                sf::Socket::Status status = m_UDPSocket.receive(*uPack, rcvAddr, rcvPort);
Note: I need the mutex since I am using multiple threads which access the UDP socket class.

Network / Selector.wait() not calling after client disconnect
« on: May 26, 2019, 01:46:25 am »
I have been working on a TCP networking game recently and have been having problems with the
function. Whenever a client disconnects the selector basically stops functioning, it will not receive any packets or even trigger after a new client tries to connect. Is this intentional as a part of the SFML engine, or is this most likely a programming error on my part?

Graphics / Creating simple 3D objects SFML
« on: April 20, 2019, 06:39:41 am »
For anyone who wants to create simple, rough, and fast 3D models I found a method from Scratch (thanks to kevin11) that works perfectly in SFML. If you separate a 3D object into 2D layers you can stack these layers to create a 3D effects and you can even rotate the objects along the y-axis. This can and will, however, be a bottleneck in your program. If there are any ideas on how to optimize this process they would be very helpful.

Network / Shifting sf::Packet into another sf::Packet
« on: April 16, 2019, 05:57:49 pm »
Is there any way to shift a sf::Packet into anoter sf::Packet as seen below(figure1)? I am trying to setup a function that takes a sf::Packet as an arguement, stamps a name on the packet, and then sends it to a client. The problem now is that all that data in the data variable(figure 2) is lost when the data variable is shifted into the newPacket variable.

sf::Packet data;
std::string name = "Bob";
int age;
data << bob <<age;

sf::Packet FinalPacket;
std::string PacketType = "Name";
FinalPacket << PacketType << data;

figure 2
bool SFMLNetwork::sendUDP(sf::Packet data, std::string Type, sf::IpAddress receiver, unsigned short rcvPort)
        sf::Packet newPacket;
// not sure if data can be shifted into newPacket
        newPacket << Type << data;
        if (UdpSocket.send(newPacket, receiver, rcvPort) == sf::Socket::Status::Done) {
                return true;
        else {
                return false;


Network / Question about: Socket Selectors and UDP
« on: June 07, 2018, 05:14:01 pm »
I'm currently working on an "Soul Knight" esk (top down shooter) game and I decided to use UDP for networking amongst players. The only problem is I don't know exactly how I should receive packets simultaneously from multiple clients on the server. Right now I have a loop going through a list of all the client IP's and client Ports calling receive commands for each client. For each packet I store a copy of it in a std::vector list. Should I continue to use this method for receivin data or use a socketSelector or some other method?

Pages: [1]