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

Pages: [1]
1
System / passing SocketTCP to thread problem
« on: December 24, 2011, 12:51:31 pm »
Thanks ;p iam so stupid i forgot this

2
System / passing SocketTCP to thread problem
« on: December 24, 2011, 11:59:34 am »
Hi! I want to pass the SocketTCP to my thread function but compiler says its private :/ i have to create listening thread so i need it.
Code: [Select]

void Client_Listen_Thread(void* UserData)
{
  sf::SocketTCP Server = static_cast<sf::SocketTCP>(UserData);
  [...] blabla


and
Code: [Select]

sf::Thread ListenThread(&Client_Listen_Thread,&Server);


Help please :(

3
Network / Trading data between multiple clients
« on: December 23, 2011, 07:45:20 am »
Hi! :) Iam rly newb in network programming, i have problem with structure of handling multiple clients with selector.

Now i do it like this:

Client class
Code: [Select]

class klient
{
  public:

  sf::SocketTCP sock;
  sf::IPAddress adres;
  string nick;
  int ID;

  klient(sf::SocketTCP soc, sf::IPAddress adr,string nck, int id)
  {
    sock = soc;
    adres = adr;
    nick = nck;
    ID = id;

  }

};



Code: [Select]

klient *klienci[10];  //array of clients
int klientnum = 0;   //number of clients


Adding Clients
Code: [Select]


[...]
here is that selector thing from tutorial, Socket==Listener etc etc
[...]
sf::IPAddress Address;
            sf::SocketTCP Client;
            Listener.Accept(Client, &Address);
            std::cout << "Client connected ! (" << Address << ")" << std::endl;

klienci[klientnum+1] = new klient(Client,Address,"default",klientnum+1); // add client data to clients array
klientnum+=1; //increse number of clients
Selector.Add(Client); //add client to selector


Recieving + (i thing wrong)Sending data
Code: [Select]

[...] its still in the selectors loop
{
sf::Packet Packet;
            if (Socket.Receive(Packet) == sf::Socket::Done)
            {
               std::string Message;
               Packet >> Message;
               std::cout << "A client says : \"" << Message << "\"" << std::endl;
               Socket.Send(Packet) == sf::Socket::Done;

//---------------------------here we go-----------------------------------
               for(int i=1;i<klientnum;i++) //loop trough array of clients
               {
                  if(klienci[i]->sock!=Socket) //if socket is not the same socket
                  {klienci[i]->sock.Send(Packet) == sf::Socket::Done;} //send data
               }

            }


My problem is, other clients dont get thier messages :/

4
Window / Problem with window
« on: October 10, 2011, 03:30:40 pm »
Yep, i use ATI card and 1.6, is there any solution? Or i have to wait for newer version or use older one ?

5
Window / Problem with window
« on: October 10, 2011, 03:08:44 pm »
Hi guys. I just installed SFML into my Code::Blocks, linked everything and include all i need but... after compile a simple program my window just does not appear! In SDL everything worked fine so its not problem with my system or somethin like this ;p

Here is the code:
Code: [Select]

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>

using namespace std;
int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML Window");

    sf::Event Event;

    while(App.IsOpened())
    {
      while(App.GetEvent(Event))
      {
        if(Event.Type == sf::Event::Closed)
        {
            App.Close();
        }

      }

      App.Clear();

      App.Display();


    }

    return EXIT_SUCCESS;

}



Everything is compling without problems, but after run i see only console but no window at all :/ Maby its something with my mingw? i don't have any clue because its my first time with this lib. Help me please ;p

Pages: [1]