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

Pages: [1]
1
Network / Re: std::vector of sockets [c++]
« on: October 16, 2016, 03:40:05 pm »
Ah okay thanks for the quick reply, my fault for not reading the error properly.

Maybe update the docs to make this a bit clearer?

http://www.sfml-dev.org/tutorials/2.3/network-socket.php

Quote
A selector is not a socket container. It only references (points to) the sockets that you add, it doesn't store them. There is no way to retrieve or count the sockets that you put inside. Instead, it is up to you to have your own separate socket storage (like a std::vector or a std::list).

2
Network / std::vector of sockets [c++]
« on: October 16, 2016, 03:24:27 pm »
I've constructed a vector of sf::TcpSockets however I can't push a socket back onto the vector.

Running:
  • Fedora 24 64 bit
  • libstdc++.so.6.0.22
  • sfml-2.3.2

Error:
Code: [Select]
/usr/include/c++/6.2.1/ext/new_allocator.h:120:4: error: use of deleted function ‘sf::TcpSocket::TcpSocket(const sf::TcpSocket&)’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code:
       
    std::vector<sf::TcpSocket> sockets;

        sf::TcpListener listener;

        // bind the listener to a port
        if (listener.listen(53000) != sf::Socket::Done)
        {
            // error...
        }

    while(true)
    {
        // accept a new connection
        sf::TcpSocket client;
        if (listener.accept(client) != sf::Socket::Done)
        {
        // error...
        }
        else
        {
            sockets.push_back(client);

            for(auto &client : sockets)
            {
/*----------------------- snip -----------------------------------*/
           

Pages: [1]
anything