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 - koker_007

Pages: [1]
1
Network / Re: UDP Failed to bind socket to port 45666
« on: June 28, 2017, 06:45:02 am »
Forgive me for waiting.
Unfortunately I could not find out which small part of the code is causing the error, so I decided to just cut out the entire block responsible for sending packets. Sorry that it did not turn out to be less code. Simply if you reduce it, the error disappears. For this reason, all the logic of sending and receiving is visible. Exactly the same as in my program. But all the logic of sending and receiving is visible, exactly as in my program.

http: / / www. filedropper.com/main_37

For work you will need more GLEW GLFW libraries. I know that SFML is able to create a window and draw with OpenGL but I want to use it only to transfer messages between devices.
Thanks for help.

2
Network / Re: UDP Failed to bind socket to port 45666
« on: June 22, 2017, 10:24:23 am »
Gleade, sorry for my English. I meant that my program both sends and receives packets on the UDP protocol. Of course, at least 2 devices are required to test the connection, in my case it is. However, an error occurs on one of the devices: "Failed to bind socket to port 45666"

Initially, when I met this error, I thought that it was due to the fact that this port is already being used on the device by some other program. But the sniffer showed that this is not true.
After checking the small (simple) SFML code, it turned out that it works, so the error is somewhere inside the logic my program. I most likely misuse SFML and I need to understand what conditions can cause this error so that I can fix it

Now I think that it arises from the fact that one and the same port is used both for sending and receiving messages, but this assumption causes me the following questions:
Why then does the error not appear on the first device, if the program works exactly the same?
Maybe my mistake is that UDP requires closing like TCP, but it's very strange and I'm in a confusion.

3
Network / Re: UDP Failed to bind socket to port 45666
« on: June 21, 2017, 10:56:51 am »
Just tell what are the reasons for the error: "Failed to bind socket to port 45666"
please.

This error is registered somewhere inside the sfml and I would like to know what conditions for its appearance, so that it could be fixed.
I have several times rewritten the code that processed the data transfer but this error remains.

4
Network / Re: UDP Failed to bind socket to port 45666
« on: June 21, 2017, 05:33:34 am »
strange... I wrote following:

int main(void)
{
        sf::IpAddress ip_in("0.0.0.0");

        unsigned short port;
        cout << "Create packet end udp socket - next" << '\n';
        system("pause");
        sf::Packet packet_sf_in;
        sf::UdpSocket  packet_sf;


        cout << "bind port 45666 - next" << '\n';
        system("pause");
        packet_sf.bind(45666);

        cout << "Set blocking 0 - next" << '\n';
        system("pause");
        packet_sf.setBlocking(0);

        cout << "receive func - next" << '\n';
        system("pause");
        sf::Socket::Status status = sf::Socket::Status::NotReady;
        status = packet_sf.receive(packet_sf_in, ip_in, port);

        if (status == sf::Socket::Status::Done) {
                cout << "Status done" << '\n';
        }
        else if (status == sf::Socket::Status::Disconnected) {
                cout << "Status Disconnected" << '\n';
        }
        else if (status == sf::Socket::Status::Error) {
                cout << "Status Error" << '\n';
        }
        else if (status == sf::Socket::Status::Partial) {
                cout << "Status Partial" << '\n';
        }

        system("pause");

}
 

This time he did not give any error...
I checked correct inclusion of library in the debag version used by sfml-network-d-2.dll
So error is not here...
I used the sniffer to find out if port is busy with another program, but it is free.
also port 45666 is open.

I do not even know where the source of the this problem.

5
Network / UDP Failed to bind socket to port 45666
« on: June 20, 2017, 06:52:33 pm »
Hello, problem with using a UDP socket. I have 2 devices, both in my application work as a receiver and as a sender. However, on one of them, errors constantly appear in the console window: "Failed to bind socket to port 45666".

Still "receive()" very often returns the status::error, but not always, sometimes it turns out to receive a message.

Function of reception in class
        void react_element() {
                send_new_data();

                sf::Packet packet_sf_in;

                sf::IpAddress ip_in("0.0.0.0");

                unsigned short port;
                sf::UdpSocket  packet_sf;

                packet_sf.bind(45666);

                packet_sf.setBlocking(0);


                for (GLushort num_try = 0 , num_packet_accept = 0; num_try < parametr.max_try_listen && num_packet_accept < parametr.max_accept_packet; num_try++) {
                        sf::Socket::Status status = sf::Socket::Status::NotReady;

                        status = packet_sf.receive( packet_sf_in, ip_in, port);

                        if (status == sf::Socket::Status::Done) {

                                num_packet_accept++;

                                if (sizeof(packet) == packet_sf_in.getDataSize()) {

                                        pack = ((packet*)packet_sf_in.getData());

                                        string ip_str;
                                        GLuint ip_int;
                                        ip_int = ip_in.toInteger();

                                        ip_str = int_ip_to_string_ip(ip_int);


                                        GLbyte ok_connect_ip = 0;
                                        GLushort num_connecion = 0;

                                        conection_data* data_pointer = 0;

                                        if (out_pack.its_new_connection_yn(ip_str)) {

                                                data_pointer = out_pack.create_new_connection(ip_str, 45666);
                                                cout << "New connection: " << ip_str << '\n';

                                        }
                                        else {

                                                data_pointer = out_pack.get_pointer_connection(ip_str);

                                        }


                                        if (data_pointer != 0) {
                                               
                                                if (data_pointer->its_new_in_packet_yn(pack->get_id_packet())) {
                                                       
                                                        Calculation_data_new_in_packet(pack, ip_str);
                                                       
                                                        pack = 0;
                                                }
                                                else {
                                                       

                                                }

                                        }


                                }
                                else {
                                        cout << "Socket in: BAD SIZE PACKET" << '\n';
                                }
                        }
                        else if (status == sf::Socket::Status::Disconnected) {
                                cout << "Socket in: Status::Disconnected " << '\n';
                        }
                        else if (status == sf::Socket::Status::Error) {
                                cout << "Socket in: Status::Error " << '\n';
                        }
                        else if (status == sf::Socket::Status::Partial) {
                                cout << "Socket in: Status::Partial " << '\n';
                        }

                }
        }
 


Parameters that are used in the same class
        packet* pack = 0;

        struct parameters{
               
                GLushort max_try_listen = 1000;
               
                GLushort max_accept_packet = 20;

                GLushort num_old_save_packet = 0;

        };
        parameters parametr;
 

There is very little written in the SFML documentation why an error occurs. Please explain more why such an error occurs and most importantly - how to solve it?

6
Network / Re: UDP and close ports
« on: February 08, 2017, 12:40:30 pm »
I'm a little progress in understanding what is happening. Now I want to know whether there is a SFML function that returns a number of the open port of the user? To me it is necessary to allow the server to send packet to the open port on the client.

7
Network / UDP and close ports
« on: February 07, 2017, 03:39:11 pm »
Hello, i'm writing a small multiplayer game of SFML only use network. I am sure that the client has closed the port used and was always closed. At first, when I was studying SFML Network, I used a TCP connection. It worked. The server receives a message from a client, and the client received from the server. But when I moved to the UDP, the server is also received reports, however, the client from the server - no. I know what is to blame for a closed port on the client side.
When SFML server sends the packet to the UDP, back comes a message that returns the status of sf::packet::status::Disconnected. SFML's documentation said that the "The TCP socket has been disconnected".
this status is returned even if my game is not active at the client.

Please explain why this is happening and how to get around using the UDP connection. Many games use UDP connection, but the client receives information from the server when the closed ports. How???

Pages: [1]