Jump to content

Linked Lists

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Andrew.Anderson.2008

Andrew.Anderson.2008

    Newbie

  • Members
  • Pip
  • 2 posts
Hello,

I've run into an interesting problem over the last few days while getting into the realm of the standard linked list library in C++ while trying to write a server app using sockets. Now, I'll be up front in saying that I'm no expert coder or anything so please do excuse the likely poor construction of the program or whatever I'm sure I'll hear about, but please do point out if there is a vital piece of the puzzle that I'm missing. The program right now is fairly simple, I already have startup, initialization, etc. running, but during the loop I make a call to a function called server_data::check_descriptors, which also happens to be the first function I've written that loops through the current descriptor list, so I am sure that this has a lot to do with the fact that this my first pass through all of this. If anyone can offer a hand I'd much appreciate it, and I promise I'll learn after being corrected the first time ;)


Here are the two classes, and the related function.
class server_data
{
        public:
        bool                              running;
        list<descriptor_data *>           descriptorList;
        list<descriptor_data *>::iterator listDescriptor;
        descriptor_data                  *descriptor;

        server_data::server_data( );
        void                               log( char *argument, ... );
        void                               log_error( char *argument, ... );
        int                                startup( int port );
        bool                               open_socket( int port );
        void                               close_socket( );
        int                                main_loop( );
        bool                               accept_connections( );
        void                               check_descriptors( );
};

class descriptor_data
{
        public:
        SERVER_DATA                       *server;
        int                                socket;
        int                                port;
        struct sockaddr_in                 address;
        char                               inbuf[MSL];
        char                               outbuf[MSL];

        void                               log( char *argument, ... );
        void                               log_error( char *argument, ... );
        bool                               read_input( );
        bool                               write_output( );
};

void server_data::check_descriptors( )
{
        list<descriptor_data *>::iterator iter;

        for( iter = this->descriptorList.begin( ); iter != this->descriptorList.end( ); iter++ )
        {
                if( iter->socket == NO_SOCKET )
                {
                        this->descriptorList.erase( iter );
                        continue;
                }
        }
        return;
}
And here is the error I get on compilation:

server.c: In member function 'void server_data::check_descriptors()':
server.c:230: error: request for member 'socket' in '* iter. std::_List_iterator<_Tp>::operator-> [with _Tp = descriptor_data*]()', which is of non-class type 'descriptor_data*'
make[1]: *** [o/server.o] Error 1


If anyone can help me out with this I'd much appreciate it, and if I'm in the wrong place with the wrong question, please do kick me out. Thanks much.

Edited by WingedPanther, 26 June 2008 - 07:50 AM.
add code tags


#2
Andrew.Anderson.2008

Andrew.Anderson.2008

    Newbie

  • Members
  • Pip
  • 2 posts
No suggestions on this problem from anyone?