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.


Messages - BananaBro_Chaos

Pages: [1]
1
Thanks for the help! I still have one question though.

I understand that there needs to be an open TCP socket on both the client and the server for communication, and both have to exist for actual communication. Currently, on my server side, I am using a function to check for incoming connections and receive the message (I have currently implemented opening and closing the socket per request as a placeholder). This function is run every time window loops.

My question is, if I keep the socket open while window loops and potential accepts more connections, is it actually possible for all of these connections to stay open? Like I said, it is just one function, so there is only one listener and socket that are running every window loop. To my understanding, every time the function loops, the existing connection is destroyed (like I said, only one client) in order to make way for a new connection. Is this actually the case, or am I misunderstanding how this works?

If this is too confusing, could you provide a code snippet of what storing the socket pointers would look like? I am currently struggling to grasp this concept for some reason.

Thank you for your help! Sorry that I responded this late.

2
I am writing a server that can connect with various clients to send and receive information. I am using TCP Sockets. Currently, I am faced with a decision. I can either keep every socket connection from the clients open until they disconnect, or I only connect with the client every time there is a prompt from the client.

The former makes it easy for the server to detect a prompt from any socket (if I'm not mistaken, a Socket Selector can achieve that); however, sockets are non-copyable, meaning I can't just store them in a vector. I can store pointers in the vector, but if the actual socket is destroyed, the pointer will be useless. This is why I am inclined to try the latter option; however, I am unsure if this is actually an efficient method of communication.

Basically, I have three questions. Firstly, which of the two methods of socket management should I use, keeping them all open or only connecting when prompted? Secondly, is there a method to store sockets, or socket pointers, in a container, like a vector, reliably? Lastly, is opening and closing a connection every time the server is prompted actually efficient?

Thank you in advance! Please inform me if my question is unclear.

3
General / sfml.js not being able to be installed via npm
« on: October 16, 2024, 03:29:59 pm »
I wanted to try and use node.js to write a server in conjunction with SFML, so I used the npm download link provided here: https://www.npmjs.com/package/sfml.js/v/0.0.1-preview.46. However, every time I ran it terminal, I always get a bunch of lines of error. Thus, I am wondering if I missed an update, or if sfml.js isn't compatible with my computer. I tried to do some researching regarding sfml.js, but there are no other links or information that I can find regarding it.

I put the terminal output below.

(click to show/hide)

I am using a MacBook Pro with an Apple M1 chip.

Any help / comments would be appreciated. Thanks!

4
Network / Re: Simple Packet test code returning errno = 30
« on: September 17, 2024, 01:21:47 pm »
Yeah it worked, I ran it from my user and the problem is gone. Thanks!

5
Network / Re: Simple Packet test code returning errno = 30
« on: September 16, 2024, 05:26:26 pm »
What I input:
c++ ./users/<NAME>/Desktop/testytesty/testytesty/main.cpp -I/opt/homebrew/Cellar/sfml/2.6.1/include -o test -L/opt/homebrew/Cellar/sfml/2.6.1/lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-network

Output:
ld: open() failed, errno=30 for 'test'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Please tell me if this is not what you are looking for. Yes, I do have my test file in Desktop, that makes it easier to access in my opinion.

6
Network / Re: Simple Packet test code returning errno = 30
« on: September 16, 2024, 03:03:16 pm »
I don't think that is the case. The file itself works if I remove the Network module, and I've done testing on it with the Graphics module. If the Network module is simply included, the code fails with the error. The Network module is implemented in the same way as the Graphics module, so I'm confused why simply including it causes the error, even if I didn't include anything related to the module.

7
Network / Simple Packet test code returning errno = 30
« on: September 15, 2024, 06:09:33 pm »
Basically, I wanted to test out Packets, so I copied and pasted some code on the tutorial into a test file. However, every time I ran the code, the error "ld: open() failed, errno=30 for 'test'" always appeared (test is the name of the file.)

I put the relevant code below:
#include <iostream>
#include "SFML/Network.hpp"
using namespace std;
using namespace sf;

int main(){
    UdpSocket socket;
       
    Uint16 x = 10;
    string s = "hello";
    double d = 0.6;
   
    Packet packet;
    packet << x << s << d;
   
    IpAddress recipientAddress = "192.168.0.5";
    unsigned short recipientPort = 10293;
   
    socket.send(packet, recipientAddress, recipientPort);
}
 

At the moment, I don't have code running to receive the file, but I expected that to be the error instead of what I have right now. After some researching, I found that errno = 30 means that it is a "Read-only file system", but that can't be the case since it worked when I tested the exact same file with only the Graphics library.

As for additional information, I am running the code on Xcode and using homebrew for SFML. My computer is a Mac with a Silicon M1 chip, and I run the code through terminal.

Please inform me if I need to add any more information/making rookie mistakes. I did already try restarting the computer, but it did nothing.

8
nevermind it fully works now apparently I needed to restart the computer and that's all

9
I did give permission to both XCode and Terminal; however, it still doesn't work. What's even weirder is that I didn't change the permission settings ever. Keyboard just worked one day and didn't the next.

10
As the title states, Keyboard::isKeyPressed is not working. To demonstrate this issue, I created a simple project to show that it does not work:

#include <iostream>
#include "SFML/Graphics.hpp"
#include "SFML/Window.hpp"
using namespace std;
using namespace sf;

RenderWindow window(VideoMode(1400, 840), "Game Window");

int main(){
    while(window.isOpen()){
        Event event;
       
        if(Keyboard::isKeyPressed(Keyboard::A)){
            cout << &#39;e&#39; << endl;
        }
        while (window.pollEvent(event)){
            if (event.type == Event::Closed){
                window.close();
            }
        }
    }
}

Even if I pressed A, nothing gets outputted.

Some additional information, I code in XCode on Mac; however, I can't run SFML directly from XCode. Instead, I downloaded SFML through homebrew and ran the code through Terminal. I don't know if this affects the code (it didn't affect it previously) but I figured I might add it.

Pages: [1]
anything