Mysql++ funktioniert nicht



  • Hi,
    Da ich von meinem Programm aus auf die Mysql Datenbank zugreifen muss hab ich mir mysql++ besorgt.
    Hab auch alles nach der Readmy installiert dennoch kommen folgende Fehler:

    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:58: error: expected ;' before '.' token ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:188: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:188: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:208: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:208: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:228: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:233: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:233: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:238: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:238: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:243: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:243: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:259: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:259: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:279: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:279: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:284: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:284: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:289: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:289: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:289: error: expected)' before "const"

    An den Fehler erkennt man das es an Boost liegt nur was kann ich da ändern?
    Auf boost kann ich nicht mehr Verzichten weil ich die in meinem Programm an sehr vielen Stellen einseze!
    Zum erstellen der libs hab ich Mysql5 benutzt!

    MFG ReduX



  • Öhm, also die Annahme, dass Boost "Schuld" ist liegt zwar nahe. Aber bist du dir sicher, dass du nicht irgendwo nen Fehler gemacht hast, bevor du was von boost eingebunden hast? Könnte ein vergessenes ";" hinter einer Klassendefinition oder so sein.



  • Hi,
    Ich weiß nicht was grad los ist aber irgendwie funktioniert das prog auch nichtmehr wenn ich das mysql++ Zeug rausmachen.
    Code:

    #include <iostream.h>
    #include <util.h>
    #include <mysql++.h>
    #include <iomanip>
    #include <string>
    #include <stdio.h>
    #include <ctime>
    #include <boost/thread/thread.hpp>
    #include <boost/thread/mutex.hpp>
    #include <boost/bind.hpp>
    #include <boost/asio.hpp>
    #include <boost/date_time/posix_time/posix_time.hpp>
    #if defined(WIN32) || defined(__WIN32__)
    #include <winsock2.h>
    #else
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <netdb.h>
    #endif
    #define MAX_CLIENTS 1500
    using namespace std;
    boost::mutex io_guard;
    boost::asio::io_service io;
    long rc;
      SOCKET acceptSocket;
      SOCKADDR_IN addr;
      char buf[320];
      int auth[MAX_CLIENTS];
      int chan[MAX_CLIENTS];
      int admin[MAX_CLIENTS];
      string nick[MAX_CLIENTS];
      int userid[MAX_CLIENTS];
      FD_SET fdSet;
      SOCKET clients[MAX_CLIENTS];
      int i;
    
    void splitstring(string str, string seperater, string &first, string &second)
    {
         int i = (int)str.find(seperater);
         if(i != -1)
         {
              int y = 0;
              if(!str.empty())
              {
                   while(y != i)
                   {
                        first += str[y++];
                   }
                   y = y+(int)seperater.length();
                   while(y != str.length())
                   {
                        second += str[y++];
                   }
    
              }
         }
         else
         {
              first = str;
              second = "NULL";
         }
    }
    
    string make_daytime_string()
    {
      time_t now = time(0);
      return ctime(&now);
    }
    
    int detect(int user,int t, string angabe)
    {
    if(auth[i] == 1)
    {
        string a;
        string b;
     splitstring(angabe,"!%!%!%!",a,b);
    if(a == "1")
    {
    splitstring(b,"!%!%!%!",b,a);
    const char* c = b.c_str();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
    if(chan[i] == chan[t]) {
    send(userid[i],c,sizeof(c),0);
    }
    }
    }
    } else if (a == "2") {
    
    } else if (a == "3") {
    
    } else if(a == "4") {
    
    } else if(a == "5") {
    
    }
    }
    }
    
    int channel(void)
    {
        for(;;) {
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(10));
    t.wait();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
       char* angabe = "hallo";
    send(userid[i],angabe,(int)strlen(angabe),0);
    }
    }
    }
    }
    
    int user(void)
    {
        for(;;) {
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(10));
    t.wait();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
        char* angabe = "hallo2";
    send(userid[i],angabe,(int)strlen(angabe),0);
    }
    }
    }
    }
    
    int userdel(int i)
    {
        chan[i]=0;
        auth[i]=0;
        admin[i]=0;
        nick[i]="0";
        userid[i]=0;
        clients[i]=INVALID_SOCKET;
    }
    
    int usernew(int user,int i)
    {
    while(clients[i] != INVALID_SOCKET) {
    if(FD_ISSET(clients[i],&fdSet))
    {
    rc=recv(user,buf,320,0);
    if(rc==0 || rc==SOCKET_ERROR)
    {
    boost::thread reaktion( boost::bind(&userdel,i));
    closesocket(user);
    } else {
    string a,b,username,password;
    splitstring(buf,"!%!%!%!",a,b);
    if(a == "0")
    {
    splitstring(b,"!%!%!%!",username,b);
    splitstring(b,"!%!%!%!",password,b);
    userid[i] = user;
    auth[i] = 1;
    chan[i] = 0;
    cout << "User engelegt" << endl;
    }
    }
    }
    }
    }
    
    int startWinsock(void)
    {
      WSADATA wsa;
      return WSAStartup(MAKEWORD(2,0),&wsa);
    }
    
    int main()
    {
    rc=startWinsock();
    acceptSocket=socket(AF_INET,SOCK_STREAM,0);
      memset(&addr,0,sizeof(SOCKADDR_IN));
      addr.sin_family=AF_INET;
      addr.sin_port=htons(8015);
      addr.sin_addr.s_addr=INADDR_ANY;
      rc=bind(acceptSocket,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
      rc=listen(acceptSocket,10);
    for(i=0;i<MAX_CLIENTS;i++)
      {
          chan[i]=0;
        clients[i]=INVALID_SOCKET;
        auth[i]=0;
        admin[i]=0;
        nick[i]="0";
        userid[i]=0;
      }
    
    boost::thread reaktion( boost::bind(&channel));
    boost::thread reaktion2( boost::bind(&user));
      while(1)
      {
    
        FD_ZERO(&fdSet);
        FD_SET(acceptSocket,&fdSet);
            for(i=0;i<MAX_CLIENTS;i++)
        {
          if(clients[i]!=INVALID_SOCKET)
          {
            FD_SET(clients[i],&fdSet);
          }
        }
          rc=select(0,&fdSet,NULL,NULL,NULL);
    if(FD_ISSET(acceptSocket,&fdSet)) {
          for(i=0;i<MAX_CLIENTS;i++)
          {
            if(clients[i]!=INVALID_SOCKET)
            {
              clients[i]=accept(acceptSocket,NULL,NULL);
              boost::thread reaktion( boost::bind(&usernew,clients[i],i));
              break;
            }
          }
    }
    
        for(i=0;i<MAX_CLIENTS;i++)
        {
          if(clients[i]==INVALID_SOCKET)
          {
            continue;
          }
          if(FD_ISSET(clients[i],&fdSet))
          {
            rc=recv(clients[i],buf,320,0);
            if(rc==0 || rc==SOCKET_ERROR)
            {
             boost::thread reaktion( boost::bind(&userdel,i));
              closesocket(clients[i]);
            }
            else
            {
              buf[rc]='\0';
    boost::thread reaktion(boost::bind(&detect,clients[i],i,buf));
            }
          }
        }
      }
    }
    

    Vor ein paar tagen konnte ich das Ding noch ohne Fehler Compilieren!
    Aber nun geht garnichts mehr 😮

    MFG ReduX



  • Eine Vermutung:
    Die windows.h fehlt.

    Ich hatte auch schonmal eine sehr ähnliche Fehlerliste bei einem inkludierten Header. Irgendwann hab ich dann die windows.h mal davor eingebunden und es lief. Und das die "fehlerhafte" Datei "old_win_sdk_compat.hpp" heißt, deutet in die Richtung.

    Aber da ich selbst Boost nicht benutze, weiß ich nicht, ob es daran liegt. Probiers aber mal so!

    gruß
    Martin



  • Noch ein Tip: sieh mal zu, dass du in Zeile 77 bis 177 Einrueckungen abringst, dann wird der Code leserlicher und man sieht recht schnell, ob z.B. eine der Klammern fehlt (sowas kann auch zu aeusserst merkwuerdigen Fehlermeldungen fuehren...



  • In der Funktion ist mir hier zwar kein Compilerfehler aufgefallen, aber evtl. ein logischer ...

    Wie ist INVALID_SOCKET genau definiert?
    Wenn es nämlich nicht als 0 definiert ist, dann ist die if in Zeile 8 immer true - und da bin ich mir nicht sicher ob das so gewünscht ist

    int user(void)
    {
        for(;;) {
          boost::asio::deadline_timer t(io, boost::posix_time::seconds(10));
          t.wait();
          for(i=0;i<MAX_CLIENTS;i++)
          {
          if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
            {
              char* angabe = "hallo2";
              send(userid[i],angabe,(int)strlen(angabe),0);
            }
          }
        }
    }
    

    Nachtrag
    bei mir ist INVALID_SOCKET definiert als (SOCKET)(~0) also theorhetisch alle Bits auf 1 ...



  • Hi,
    Danke für euere Hilfe.
    Also ich habe jetzt mal INVALID_SOCKET als 0 definiert und den windows header eingebunden, nun kommen folgende Meldungen:

    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    In file included from ../boost/boost/asio/detail/win_local_free_on_block_exit.hpp:27,
    from ../boost/boost/asio/system_exception.hpp:33,
    from ../boost/boost/asio/detail/win_mutex.hpp:26,
    from ../boost/boost/asio/detail/mutex.hpp:27,
    from ../boost/boost/asio/detail/service_registry.hpp:25,
    from ../boost/boost/asio/io_service.hpp:32,
    from ../boost/boost/asio/basic_io_object.hpp:20,
    from ../boost/boost/asio/basic_socket.hpp:20,
    from ../boost/boost/asio/basic_datagram_socket.hpp:25,
    from ../boost/boost/asio.hpp:18,
    from C:\chat\main.cpp:11:
    ../boost/boost/asio/detail/socket_types.hpp:44:1: warning: "FD_SETSIZE" redefined
    In file included from ../mysql++/lib/common.h:43,
    from ../mysql++/lib/connection.h:38,
    from ../mysql++/lib/mysql++.h:56,
    from ../mysql++/examples/util.h:31,
    from C:\chat\main.cpp:2:
    C:/MinGW/include/winsock.h:35:1: warning: this is the location of the previous definition
    In file included from ../boost/boost/asio/detail/socket_types.hpp:59,
    from ../boost/boost/asio/detail/win_local_free_on_block_exit.hpp:27,
    from ../boost/boost/asio/system_exception.hpp:33,
    from ../boost/boost/asio/detail/win_mutex.hpp:26,
    from ../boost/boost/asio/detail/mutex.hpp:27,
    from ../boost/boost/asio/detail/service_registry.hpp:25,
    from ../boost/boost/asio/io_service.hpp:32,
    from ../boost/boost/asio/basic_io_object.hpp:20,
    from ../boost/boost/asio/basic_socket.hpp:20,
    from ../boost/boost/asio/basic_datagram_socket.hpp:25,
    from ../boost/boost/asio.hpp:18,
    from C:\chat\main.cpp:11:
    C:/MinGW/include/ws2tcpip.h:121: error: redefinition of struct ip_mreq' C:/MinGW/include/winsock.h:278: error: previous definition ofstruct ip_mreq'
    In file included from ../boost/boost/asio/detail/socket_types.hpp:71,
    from ../boost/boost/asio/detail/win_local_free_on_block_exit.hpp:27,
    from ../boost/boost/asio/system_exception.hpp:33,
    from ../boost/boost/asio/detail/win_mutex.hpp:26,
    from ../boost/boost/asio/detail/mutex.hpp:27,
    from ../boost/boost/asio/detail/service_registry.hpp:25,
    from ../boost/boost/asio/io_service.hpp:32,
    from ../boost/boost/asio/basic_io_object.hpp:20,
    from ../boost/boost/asio/basic_socket.hpp:20,
    from ../boost/boost/asio/basic_datagram_socket.hpp:25,
    from ../boost/boost/asio.hpp:18,
    from C:\chat\main.cpp:11:
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:58: error: expected ;' before '.' token ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:188: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:188: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:188: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:208: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:208: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:208: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected unqualified-id before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:228: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:228: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:233: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:233: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:233: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:238: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:238: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:238: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:243: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:243: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:243: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:259: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:259: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:259: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:279: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:279: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:279: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:284: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:284: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:284: error: expected)' before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:289: error: expected unqualified-id before "const"
    ../boost/boost/asio/detail/old_win_sdk_compat.hpp:289: error: expected )' before "const" ../boost/boost/asio/detail/old\_win\_sdk_compat.hpp:289: error: expected)' before "const"

    Und hier nochmal der aktuelle Code:

    #include <iostream.h>
    #include <util.h>
    #include <mysql++.h>
    #include <iomanip>
    #include <string>
    #include <stdio.h>
    #include <ctime>
    #include <boost/thread/thread.hpp>
    #include <boost/thread/mutex.hpp>
    #include <boost/bind.hpp>
    #include <boost/asio.hpp>
    #include <windows.h>
    #include <boost/date_time/posix_time/posix_time.hpp>
    #if defined(WIN32) || defined(__WIN32__)
    #include <winsock2.h>
    #else
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <netdb.h>
    #endif
    #define MAX_CLIENTS 1500
    #define INVALID_SOCKET 0
    using namespace std;
    boost::mutex io_guard;
    boost::asio::io_service io;
    long rc;
      SOCKET acceptSocket;
      SOCKADDR_IN addr;
      char buf[320];
      int auth[MAX_CLIENTS];
      int chan[MAX_CLIENTS];
      int admin[MAX_CLIENTS];
      string nick[MAX_CLIENTS];
      int userid[MAX_CLIENTS];
      FD_SET fdSet;
      SOCKET clients[MAX_CLIENTS];
      int i;
    
    void splitstring(string str, string seperater, string &first, string &second)
    {
         int i = (int)str.find(seperater);
         if(i != -1)
         {
              int y = 0;
              if(!str.empty())
              {
                   while(y != i)
                   {
                        first += str[y++];
                   }
                   y = y+(int)seperater.length();
                   while(y != str.length())
                   {
                        second += str[y++];
                   }
    
              }
         }
         else
         {
              first = str;
              second = "NULL";
         }
    }
    
    string make_daytime_string()
    {
      time_t now = time(0);
      return ctime(&now);
    }
    
    int detect(int user,int t, string angabe)
    {
    if(auth[i] == 1)
    {
    
        string a;
        string b;
     splitstring(angabe,"!%!%!%!",a,b);
    
    if(a == "1")
    {
    
    splitstring(b,"!%!%!%!",b,a);
    const char* c = b.c_str();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
    
    if(chan[i] == chan[t]) {
    send(userid[i],c,sizeof(c),0);
    
    }
    }
    }
    }
    else if (a == "2") {
    
    } else if (a == "3") {
    
    } else if(a == "4") {
    
    } else if(a == "5") {
    
    }
    }
    }
    
    int channel(void)
    {
    
    for(;;) {
    
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(10));
    t.wait();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
    
       char* angabe = "hallo";
    send(userid[i],angabe,(int)strlen(angabe),0);
    }
    }
    }
    }
    
    int user(void)
    {
    
        for(;;) {
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(10));
    t.wait();
    for(i=0;i<MAX_CLIENTS;i++)
    {
    
    if(clients[i]!=0 || clients[i]!=INVALID_SOCKET)
    {
    
        char* angabe = "hallo2";
    send(userid[i],angabe,(int)strlen(angabe),0);
    
    }
    }
    }
    }
    
    int userdel(int i)
    {
    
        chan[i]=0;
        auth[i]=0;
        admin[i]=0;
        nick[i]="0";
        userid[i]=0;
        clients[i]=INVALID_SOCKET;
    }
    
    int usernew(int user,int i)
    {
    while(clients[i] != INVALID_SOCKET) {
    if(FD_ISSET(clients[i],&fdSet))
    {
    
    rc=recv(user,buf,320,0);
    if(rc==0 || rc==SOCKET_ERROR)
    {
    
    boost::thread reaktion( boost::bind(&userdel,i));
    closesocket(user);
    
    } else {
    string a,b,username,password;
    splitstring(buf,"!%!%!%!",a,b);
    if(a == "0")
    {
    splitstring(b,"!%!%!%!",username,b);
    splitstring(b,"!%!%!%!",password,b);
    userid[i] = user;
    auth[i] = 1;
    chan[i] = 0;
    cout << "User engelegt" << endl;
    }
    }
    }
    }
    }
    
    int startWinsock(void)
    {
      WSADATA wsa;
      return WSAStartup(MAKEWORD(2,0),&wsa);
    }
    
    int main()
    {
    rc=startWinsock();
    acceptSocket=socket(AF_INET,SOCK_STREAM,0);
      memset(&addr,0,sizeof(SOCKADDR_IN));
      addr.sin_family=AF_INET;
      addr.sin_port=htons(8015);
      addr.sin_addr.s_addr=INADDR_ANY;
      rc=bind(acceptSocket,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
      rc=listen(acceptSocket,10);
    for(i=0;i<MAX_CLIENTS;i++)
      {
          chan[i]=0;
        clients[i]=INVALID_SOCKET;
        auth[i]=0;
        admin[i]=0;
        nick[i]="0";
        userid[i]=0;
      }
    
    boost::thread reaktion( boost::bind(&channel));
    boost::thread reaktion2( boost::bind(&user));
      while(1)
      {
    
        FD_ZERO(&fdSet);
        FD_SET(acceptSocket,&fdSet);
            for(i=0;i<MAX_CLIENTS;i++)
        {
          if(clients[i]!=INVALID_SOCKET)
          {
            FD_SET(clients[i],&fdSet);
          }
        }
          rc=select(0,&fdSet,NULL,NULL,NULL);
    if(FD_ISSET(acceptSocket,&fdSet)) {
          for(i=0;i<MAX_CLIENTS;i++)
          {
            if(clients[i]!=INVALID_SOCKET)
            {
              clients[i]=accept(acceptSocket,NULL,NULL);
              boost::thread reaktion( boost::bind(&usernew,clients[i],i));
              break;
            }
          }
    }
    
        for(i=0;i<MAX_CLIENTS;i++)
        {
          if(clients[i]==INVALID_SOCKET)
          {
            continue;
          }
          if(FD_ISSET(clients[i],&fdSet))
          {
            rc=recv(clients[i],buf,320,0);
            if(rc==0 || rc==SOCKET_ERROR)
            {
             boost::thread reaktion( boost::bind(&userdel,i));
              closesocket(clients[i]);
            }
            else
            {
              buf[rc]='\0';
    boost::thread reaktion(boost::bind(&detect,clients[i],i,buf));
            }
          }
        }
      }
    }
    

    Hoffe das Hilft weiter...

    MFG ReduX



  • WTF? Du kannst doch nicht einfach die Konstanten aus der windows.h
    umändern!

    zu deinen Includes:

    #include <iostream>
    #include <cstdio>

    nicht die veralteten Versionen der Header nehmen
    ach ja: winsock2.h wird schon in windows.h eingebunden, nicht nochmal einbinden



  • Hi,
    Habs umgeändert aber funktionieren tuts deshalba auch nicht.

    MFG ReduX



  • Hi,
    Edit:
    Hab den Fehler gefunden es war asio mit dem Sleep Timer nur warum? die parameter stimmten doch!

    MFG ReduX



  • Hi,
    Wenn ich nun mysql++ einbinde bekomme ich auch 3 link errors:

    ../mysql++/lib/lockable.h:(.text$_ZN7mysqlpp10Connection5closeEv[mysqlpp::Connection::close()]+0x10): undefined reference to `mysql_close@4'
    ../mysql++/lib/lockable.h:(.text$_ZN7mysqlpp6ResUse9fetch_rowEv[mysqlpp::ResUse::fetch_row()]+0x6f): undefined reference to `mysql_fetch_row@4'
    ../mysql++/lib/lockable.h:(.text$_ZN7mysqlpp6ResUse9fetch_rowEv[mysqlpp::ResUse::fetch_row()]+0x83): undefined reference to `mysql_fetch_lengths@4'
    

    Hat das irgendwas mit meinem Mingw zu tun? weil in der Doku steht das es so wei ich es mache gehen müsste!

    MFG ReduX



  • Hast du die Library dazugelinkt?



  • Hi,
    Ja ich habe die Lib dazugelinkt.
    Über google habe ich folgendes gefunden:
    http://bugs.mysql.com/bug.php?id=8906
    Aber ich habe die Libs für den Mingw mit dem dlltool erstellt!

    MFG ReduX


Anmelden zum Antworten