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

Pages: [1]
1
Network / Re: Realtime server client conversation
« on: November 06, 2012, 03:20:06 am »

2
Network / Re: Why doesn't work selector.wait with UDPSocket
« on: October 28, 2012, 10:38:34 pm »
Hello everybody.


I'm using SFML 2.0 RC and I have this code, but doesn't wait doesn't work.

sf::SocketSelector selector;
        sf::UdpSocket socket;
        selector.add(socket);  
        sf::Packet p;
        p << 10; //arbitrary data

        socket.send(p,sf::IpAddress::getLocalAddress(),1010);

        selector.wait(sf::seconds(10)); //should wait 10 seconds       
        if(selector.isReady(socket))
        {
                sf::IpAddress ip;
                uint16 port;
                if(socket.receive(p,ip,port) == sf::Socket::Done)
                {
                        printf("Receive data\n");
                }
        }
        else
        {
                printf("Not ready\n");
        }
 

Some time ago using BSD Socket and WinSock and it worked. And not because it does not work if it should be like

Greetings!


#include <cstdlib>
#include <SFML/Network.hpp>

int main(int argc, char **argv)
{
      sf::SocketSelector selector;
        sf::UdpSocket socket;
       
        sf::Packet p;
        p << 10; //arbitrary data

        if(socket.bind(3030) != sf::Socket::Done)
        {
                printf(":C no bind");
        }

        selector.add(socket);  

        socket.send(p,sf::IpAddress::getLocalAddress(),4030); //if remove this line, the program wait 10 seconds
        //socket.send(p,sf::IpAddress("192.168.1.31"),4040); //or use this line works!

        printf("...");
        selector.wait(sf::seconds(10)); //should wait 10 seconds       
        printf("...\n");
        if(selector.isReady(socket))
        {
                sf::IpAddress ip;
                uint16 port;
                if(socket.receive(p,ip,port) == sf::Socket::Done)
                {
                        printf("Receive data\n");
                }
                else
                {
                        printf("None\n");
                }
        }
        else
        {
                printf("Not ready\n");
        }
       
        system("pause");
}
 

This is a minimal code

Edit:Don't worry I will use the old implementation for this (with WinSock)
Thanks you!

3
Network / Re: Why doesn't work selector.wait with UDPSocket
« on: October 28, 2012, 08:39:59 pm »
Why should it wait? Since you send something, it immediately has something to receive.

I'ts correct, but I change the destination port and nothing...

So it waits either for a socket to become ready OR the timeout to expire whichever comes first. It does not have to wait for the timeout.
This is also standard behavior in all the other socket APIs out there.

So the UDPSocket is always ready? I can't understand this because I don't send any data to socket.

I check my code and see some curiosities  :o

If I don't send anydata to localhost IT'S WORKS the program wait 60 seconds.
If I send anydata to localhost but to anyport the program(except 1010) don't wait 60 seconds but don't receive any data (of course).

This is a problem when code test the client and server.

Thanks  :)


4
Network / Re: Why doesn't work selector.wait with UDPSocket
« on: October 27, 2012, 11:09:05 pm »
What does "doesn't work" mean? What happens?
:-X
...

The program doesn't wait a 60 seconds (or any time) when execute this line "selector.wait(sf::seconds(60))"

5
Network / Re: Why doesn't work selector.wait with UDPSocket
« on: October 27, 2012, 09:30:14 pm »
Now I have this code, but doesn't work too  :(
sf::SocketSelector selector;
        sf::UdpSocket socket;  
        sf::Packet p;
        p << 10; //arbitrary data      
        socket.bind(1010);
        socket.send(p,sf::IpAddress::getLocalAddress(),1010);
        selector.add(socket);          
        printf("Emm....");
        selector.wait(sf::seconds(60));
        printf("...Yes\n");
       
        if(selector.isReady(socket))
        {
                sf::IpAddress ip;
                uint16 port=1010;
                if(socket.receive(p,ip,port) == sf::Socket::Done)
                {
                        printf("Data!!\n");
                }
        }
        else
        {
                printf("Not ready\n");
        }

6
Network / Re: Why doesn't work selector.wait with UDPSocket
« on: October 27, 2012, 05:10:56 pm »
The port specified in the send function can be different to the port specified in the receive function because it is automatically assigned by OS (or manually assigned)

I tried what you said, but nothing.

I think the real problem is located in SocketSelector, I'll have to look at the source code.
EDIT:(I check the source code, but I can't found any problem)

Thanks!

7
Network / Why doesn't work selector.wait with UDPSocket
« on: October 27, 2012, 01:00:24 am »
Hello everybody.


I'm using SFML 2.0 RC and I have this code, but doesn't wait doesn't work.

sf::SocketSelector selector;
        sf::UdpSocket socket;
        selector.add(socket);  
        sf::Packet p;
        p << 10; //arbitrary data

        socket.send(p,sf::IpAddress::getLocalAddress(),1010);

        selector.wait(sf::seconds(10)); //should wait 10 seconds       
        if(selector.isReady(socket))
        {
                sf::IpAddress ip;
                uint16 port;
                if(socket.receive(p,ip,port) == sf::Socket::Done)
                {
                        printf("Receive data\n");
                }
        }
        else
        {
                printf("Not ready\n");
        }
 

Some time ago using BSD Socket and WinSock and it worked. And not because it does not work if it should be like

Greetings!

8
Network / Can I use Multicast?
« on: January 17, 2011, 03:58:56 pm »
Ohh, Thank you

9
Network / Can I use Multicast?
« on: October 31, 2010, 03:57:30 pm »
Hello everybody.
I have a question, Can I use Multicast with SFML?
I use SFML 2

Thank!!

Pages: [1]
anything