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

Pages: [1]
1
Network / Re: Looping through clients with TCP selector
« on: March 26, 2012, 01:52:00 pm »
Okay, then it makes sense that I didn't find anything (:

2
Network / Looping through clients with TCP selector
« on: March 26, 2012, 10:12:12 am »
Can't find anything on how to loop through a tcp selector without them having to send packets to make the socket ready.

I want to be able to send packets to them...

3
Network / UDP socket
« on: February 16, 2012, 02:32:52 pm »
The problem does not occur when I set the socket to blocking /:

Need some time to think about this...

4
Network / Minimal Code
« on: February 16, 2012, 08:15:12 am »
This code recreates the problem (:

Code: [Select]
#include <SFML/Network.hpp>
#include <iostream>

void Receive();

sf::SocketUDP Socket;

int main()
{
    std::cout << "Send or receive (0/1): ";
    int choice;
    std::cin >> choice;

    if (choice == 1)
    {
        Socket.Bind(4639);
        Socket.SetBlocking(false);

        while (true)
        {
            Receive();
        }
    }
    else
    {
        while (true)
        {
            sf::Packet Packet;
            Packet << 1;
            Socket.Send(Packet, "localhost", 4639);
        }
    }

    return EXIT_SUCCESS;
}


void Receive()
{
    sf::Packet Packet;
    sf::IPAddress IP;
    unsigned short port;

    Socket.Receive(Packet, IP, port);

    if (IP != "255.255.255.255")
    {
        int PType = -1;
        Packet >> PType;

        if (PType == -1)
        {
            std::cout << "Bad Packet!" << std::endl;
        }

        std::cout << "Packet received! IP: " << IP << " Port: " << port << " Packet Type: " << PType << std::endl;

    }
}

5
Network / UDP socket
« on: February 13, 2012, 10:12:36 am »
I added some console prints to find where the program stops. And the problem is that it won't go further than when I call receive.

It returns the whole function if the receive call isn't equal to sf::Socket::Done and IsValid returns 1 at all times...

6
Network / UDP socket
« on: February 13, 2012, 08:23:18 am »
I'm writing a client/server interface for a game my friends and I are working on and have stumbled upon a couple of problems.

First one:
Whenever I call receive on my listening UDP socket and no data has been sent to the server it receives from 255.255.255.255, is that normal?

Second one:
After a while of receiving data from a client it just stops to listen (I think, don't exactly know what's wrong). I can still send data to my client (from another socket) but it doesn't react to any received data and it's always random. Sometimes I'm able to send 50 and sometimes it just handles three.

Here is a paste of how I handle incoming connections http://pastebin.com/LGaSQRKz

7
Network / how does a client find a computer running the server
« on: January 22, 2012, 12:34:13 pm »
Think most people would broadcast the ip of the host throughout the network and then clients could pick up on that.

Don't know if sfml supports broadcasts but that's how most games and programs do it...

8
Network / Using UDP sockets with graphics packet
« on: October 21, 2011, 06:30:37 pm »
When I send a regular packet containing an int and two strings between these two loops everything works fine.

Code: [Select]
sf::Packet Packet;
    sf::IPAddress IP;
    unsigned short Port;

    std::cout << "Waiting for clients..." << std::endl;
    Socket.Receive(Packet, IP, Port);
    std::cout << "Connection received!" << std::endl;

    int Type;

    if (Packet >> Type == 1)
    {
        std::string userName, Password;

        Packet >> userName >> Password;

        std::cout << "Username: " << userName << " Password: " << Password << std::endl;
    }

Code: [Select]
       sf::SocketUDP UDP;

        sf::Packet testPacket;
        int Type = 1;
        std::string userName = "00";
        std::string password = "00";

        std::cout << "Enter username: ";
        std::getline(std::cin, userName);
        std::cout << "Enter password: ";
        std::getline(std::cin, password);

        sf::IPAddress Address = "127.0.0.1";
        unsigned short portNr = 4639;

        testPacket << Type << userName << password;
        UDP.Send(testPacket, Address, portNr);
        std::cout << "Sent Login to " << Address << ":" << portNr << std::endl;


But when I have the same client code within a client rendering a window the socket doesen't go through to the server.

The client renders a single frame with a loaded image then pauses for input from user, that's the only difference between the client I want to use and this code...

So do anyone have an idea why this would be?

9
General / Getting Linker errors trying to install 1.6 VS2010
« on: March 04, 2011, 11:15:45 pm »
Still the same error message... :/

10
General / Getting Linker errors trying to install 1.6 VS2010
« on: March 04, 2011, 10:49:49 pm »
Hi, so I'm getting linker errors from the first windows tutorial in the 1.6 section...

The first sf::Clock tutorial works but when I follow the window tutorial I get these errors:
Code: [Select]
1>------ Build started: Project: SFML-Test, Configuration: Debug Win32 ------
1>  main.cpp
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>E:\C++\SFML-Test\Debug\SFML-Test.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Here is the source of the program (grabbed from the tutorial)
Code: [Select]
#include <SFML/Window.hpp>

int main()
{
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
bool Running = true;
while (Running)
{
   App.Display();
}

return EXIT_SUCCESS;
}


I've recompiled the libraries and added the "sfml-system-s-d.lib;sfml-main.lib;" to the Input under Linker in the project options. I've also added the "SFML_DYNAMIC" to the preprocessor.

I use Win7 x64 with VS2010.

I'd really like to start using SFML :)[/code]

Pages: [1]
anything