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

Pages: [1]
1
Network / Re: Unhandled exception: Access violation
« on: July 24, 2013, 12:11:58 am »
Oops!
Found it. The last for-loop deleting all the sockets, was in the while loop which uses the sockets. This is truly wrong

2
Network / Re: Unhandled exception: Access violation
« on: July 23, 2013, 11:54:02 pm »
Have you ever heard of the magical tool debugger? Try to run it through that and find out what causes the problem.
1. I'm using Visual Studio. It has a debugger. But it sayed nothing helpful.
just
Quote from: VC++Debugger
Access violation when reading at position 0xFEEEFEEE.
!

Also you shouldn't use manual memory management, but rather make use of RAII and smart pointers. ;)
2. I think manual memory management is okay for the moment

3
Network / Unhandled exception: Access violation
« on: July 23, 2013, 11:14:11 pm »
Hi,
I've made a little chatprogramm(just for fun ;) ) and I have this little problem you can see in the title.

the full error message is
"Unhandled exception at 0x773f15de in sfmlserver.exe: 0xC0000005: Access violation."
It pops up everytime my client is connecting to my server (both on my computer).

Actually I don't even know if the connection causes the problem.
code of the server:
#include<SFML\Audio.hpp>
#include<SFML\Graphics.hpp>
#include<SFML\Network.hpp>
#include<iostream>
#include<string>
#include<vector>
#include<conio.h>
int main()
{
        std::cout<<"server is online"<<std::endl;
        sf::TcpListener list;
        sf::SocketSelector select;
        std::vector<sf::TcpSocket*> clients;
        list.listen(50000);
        select.add(list);
        while(true){
                if(select.wait()){
                        if(select.isReady(list)){
                                sf::TcpSocket *socket = new sf::TcpSocket;
                                list.accept(*socket);
                                sf::Packet packet;
                                std::string id;
                                if(socket->receive(packet)==sf::Socket::Done)
                                                packet>>id;

                                std::cout<< id << " has joined the chatroom" << std::endl;
                                clients.push_back(socket);
                                select.add(*socket);
                        }
                        else{
                                for(int i=0;i<clients.size();i++){
                               
                                        if(select.isReady(*clients[i])){
                                                sf::Packet pack;
                                                if(clients[i]->receive(pack)==sf::Socket::Done){
                                                        std::string text;
                                                        for(int j=0;i<clients.size();j++){
                                                                if(j!=i){
                                                                        clients[j]->send(pack);
                                                                }      
                                                        }
                                                }
                                        }
                                }
                        }
                }
        for(std::vector<sf::TcpSocket*>::iterator it=clients.begin(); it!=clients.end();it++)
                delete *it;
        }
        system("pause");
        return 0;
}
 

Pages: [1]
anything