TIdTCPClient dynamisch erstellen



  • Hallo zusammen

    Ich versuche gerade einen Indy TCP Client Verbindung aufzubauen.

    TIdTCPClient *TcpClient;
        TcpClient = new TIdTCPClient(NULL);
        AnsiString sAnswer;
        int iReturn = 1;
    
        //config tcp client
        TcpClient->Host = "127.0.0.1";
        TcpClient->Port = 8090;
    
        if(!TcpClient->Connected())
        {
            TcpClient->Connect();   //Zugriffsverletzung
        }
        ...
    

    Sobald ich jedoch versuch mich mit dem Server zu verbinden bekomme ich eine Zugriffsverletzung.

    Exception class: EAccessViolation
    Exception message: Zugriffsverletzung bei Adresse 00435FBC in Modul 'protcopclient.exe'. Lesen von Adresse 00001F92.
    Exception address: 00435FBC
    ------------------------------------------------------------------------------
    Stack list, generated 29.01.2009 16:04:01
    (00034FBC){protcopclient.exe} [00435FBC] D:\PROGRAM.System::__linkproc__ __fastcall LStrAsg + $4
    (00004AD5){protcopclient.exe} [00405AD5] D:\PROGRAM.__fastcall Idiohandlersocket::TIdIOHandlerSocket::ConnectClient + $A1
    (00008CF6){protcopclient.exe} [00409CF6] D:\PROGRAM.__fastcall Idtcpclient::TIdTCPClient::Connect + $F2
    (000798C0){protcopclient.exe} [0047A8C0] D:\PROGRAM.__fastcall System::AnsiString::~AnsiString + $14
    (00000ED0){protcopclient.exe} [00401ED0] C:\PROJECTS\PROTOKOLL\SOURCE_CODE\PROTOCOLCOPIER\UNIT1.OBJ.SendProtCopSvrCmd + $E0
    (00032C1E){protcopclient.exe} [00433C1E] D:\PROGRAM.__fastcall System::SysGetMem + $176
    (00034AA0){protcopclient.exe} [00435AA0] D:\PROGRAM.System::__linkproc__ __fastcall TryFinallyExit + $10
    (00032B9D){protcopclient.exe} [00433B9D] D:\PROGRAM.__fastcall System::SysGetMem + $F5
    (0006643F){protcopclient.exe} [0046743F] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $157
    (000633C0){protcopclient.exe} [004643C0] D:\PROGRAM.__fastcall Controls::TControl::Perform + $24
    (00062172){protcopclient.exe} [00463172] D:\PROGRAM.__fastcall Controls::TControl::GetTextBuf + $6
    (00000CE4){protcopclient.exe} [00401CE4] C:\PROJECTS\PROTOKOLL\SOURCE_CODE\PROTOCOLCOPIER\UNIT1.OBJ.__fastcall TForm1::Button1Click + $3C
    (0003439E){protcopclient.exe} [0043539E] D:\PROGRAM.System::__linkproc__ __fastcall IsClass + $E
    (00063788){protcopclient.exe} [00464788] D:\PROGRAM.__fastcall Controls::TControl::Click + $64
    (0003F384){protcopclient.exe} [00440384] D:\PROGRAM.__fastcall Stdctrls::TButton::Click + $1C
    (0003F478){protcopclient.exe} [00440478] D:\PROGRAM.__fastcall Stdctrls::TButton::CNCommand + $C
    (000635F0){protcopclient.exe} [004645F0] D:\PROGRAM.__fastcall Controls::TControl::WndProc + $188
    (0006643F){protcopclient.exe} [0046743F] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $157
    (0003F2F8){protcopclient.exe} [004402F8] D:\PROGRAM.__fastcall Stdctrls::TButtonControl::WndProc + $6C
    (000633C0){protcopclient.exe} [004643C0] D:\PROGRAM.__fastcall Controls::TControl::Perform + $24
    (00066577){protcopclient.exe} [00467577] D:\PROGRAM.Controls::_16864 + $23
    (00066BD3){protcopclient.exe} [00467BD3] D:\PROGRAM.__fastcall Controls::TWinControl::WMCommand + $B
    (00056628){protcopclient.exe} [00457628] D:\PROGRAM.__fastcall Forms::TCustomForm::WMCommand + $2C
    (000635F0){protcopclient.exe} [004645F0] D:\PROGRAM.__fastcall Controls::TControl::WndProc + $188
    (00066523){protcopclient.exe} [00467523] D:\PROGRAM.__fastcall Controls::TWinControl::DefaultHandler + $D7
    (000635F0){protcopclient.exe} [004645F0] D:\PROGRAM.__fastcall Controls::TControl::WndProc + $188
    (0006643F){protcopclient.exe} [0046743F] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $157
    (000126DC){protcopclient.exe} [004136DC] D:\PROGRAM.__fastcall Classes::TThreadList::UnlockList + $4
    (0004B594){protcopclient.exe} [0044C594] D:\PROGRAM.__fastcall Graphics::FreeMemoryContexts + $98
    (0005474D){protcopclient.exe} [0045574D] D:\PROGRAM.__fastcall Forms::TCustomForm::WndProc + $421
    (000660BC){protcopclient.exe} [004670BC] D:\PROGRAM.__fastcall Controls::TWinControl::MainWndProc + $2C
    (0001C624){protcopclient.exe} [0041D624] D:\PROGRAM.Classes::_17260 + $14
    (00066523){protcopclient.exe} [00467523] D:\PROGRAM.__fastcall Controls::TWinControl::DefaultHandler + $D7
    (00063B90){protcopclient.exe} [00464B90] D:\PROGRAM.__fastcall Controls::TControl::WMLButtonUp + $10
    (000635F0){protcopclient.exe} [004645F0] D:\PROGRAM.__fastcall Controls::TControl::WndProc + $188
    (00066371){protcopclient.exe} [00467371] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $89
    (0006643F){protcopclient.exe} [0046743F] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $157
    (000126DC){protcopclient.exe} [004136DC] D:\PROGRAM.__fastcall Classes::TThreadList::UnlockList + $4
    (00066267){protcopclient.exe} [00467267] D:\PROGRAM.__fastcall Controls::TWinControl::IsControlMouseMsg + $13
    (0006643F){protcopclient.exe} [0046743F] D:\PROGRAM.__fastcall Controls::TWinControl::WndProc + $157
    (0003F2F8){protcopclient.exe} [004402F8] D:\PROGRAM.__fastcall Stdctrls::TButtonControl::WndProc + $6C
    (000660BC){protcopclient.exe} [004670BC] D:\PROGRAM.__fastcall Controls::TWinControl::MainWndProc + $2C
    (0001C624){protcopclient.exe} [0041D624] D:\PROGRAM.Classes::_17260 + $14
    (0001EBE6){protcopclient.exe} [0041FBE6] D:\PROGRAM.__fastcall Contnrs::TComponentList::GetItems + $A
    (0005A84B){protcopclient.exe} [0045B84B] D:\PROGRAM.__fastcall Forms::TApplication::ProcessMessage + $83
    (0005A86A){protcopclient.exe} [0045B86A] D:\PROGRAM.__fastcall Forms::TApplication::HandleMessage + $A
    (0005AA8A){protcopclient.exe} [0045BA8A] D:\PROGRAM.__fastcall Forms::TApplication::Run + $96
    (000008CA){protcopclient.exe} [004018CA] C:\PROJECTS\PROTOKOLL\SOURCE_CODE\PROTOCOLCOPIER\PROTCOPCLIENT.OBJ.WinMain + $46
    (00075754){protcopclient.exe} [00476754] D:\PROGRAM.__startup + $14C
    ------------------------------------------------------------------------------
    System : Windows XP Professional, Version: 5.1, Build: A28, "Service Pack 3"
    Processor: Intel, Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz, 2880 MHz MMX SSE SSE2 SSE3 SSSE3 64 bits DEP
    Memory: 2047; free 2047
    Display : 1280x1024 pixels, 32 bpp
    ------------------------------------------------------------------------------

    Das komische an der Sache ist jedoch, daß wenn ich den Code auf einem anderen PC (gleiche Indy Version 9) kompiliere ist der Fehler weg und es funktioniert alles.

    Ist mein Code soweit Ok?
    Hat irgendjemand eine Idee?

    Mfg
    Stephan


Anmelden zum Antworten