 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Liu Shan Guest
|
Posted: Thu Jan 05, 2006 9:54 am Post subject: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Hi, Everybody,
I'm a new user for Indy. Recently I download Indy v9.0.17 and installed it
on my BCB6, no problem. I try to cerate a simple server app, I draw and drop
a IdAntiFreeze on my form, once I build it, I got :
[Linker Error] Unresolved external 'Idantifreeze::TIdAntiFreeze::'
referenced from F:BCB6_TESTINDYCLIENTSERVERSERVERMAIN.OBJ
Can anybody tell me how to solve this problem? Very thanks.
Susan
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jan 05, 2006 6:05 pm Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | I'm a new user for Indy. Recently I download Indy v9.0.17
and installed it on my BCB6, no problem.
|
9.0.17 is very old. The latest snapshot build is 9.0.50.
| Quote: | I try to cerate a simple server app, I draw and drop a
IdAntiFreeze on my form
|
TIdAntiFreeze has very little effect, if any, on server components.
| Quote: | once I build it, I got :
[Linker Error] Unresolved external 'Idantifreeze::TIdAntiFreeze::'
referenced from F:BCB6_TESTINDYCLIENTSERVERSERVERMAIN.OBJ
|
Did you remove Indy 8 first? BCB6 ships with Indy 8 pre-installed, and it
must be removed from the machine before Indy 9 will work properly. There
are removal instructions in Indy's Knowledge Base at
http://www.indyproject.org/KB/.
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Fri Jan 06, 2006 1:47 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Hi,
Very thanks for your reply.
| Quote: | 9.0.17 is very old. The latest snapshot build is 9.0.50.
Where can I get the version 9.0.50? |
I've read newsgroup said Indy 10 cannot work properly with BCB6, so I try to
use Indy 9.x.
I went to http://www.indyproject.org/Sockets/Download/Files/Indy9.en.html
only can find 9.0.18, but I cannot find any batch file inside, so I download
9.0.17 and installed on my PC last time.
| Quote: | TIdAntiFreeze has very little effect, if any, on server components.
I read doc said TIdAntiFreeze can use to prevent User Interface being |
frozen.if is little effect, then how to do?
| Quote: | once I build it, I got :
[Linker Error] Unresolved external 'Idantifreeze::TIdAntiFreeze::'
referenced from F:BCB6_TESTINDYCLIENTSERVERSERVERMAIN.OBJ
Did you remove Indy 8 first? BCB6 ships with Indy 8 pre-installed, and it
must be removed from the machine before Indy 9 will work properly. There
are removal instructions in Indy's Knowledge Base at
http://www.indyproject.org/KB/.
|
I'm sure I've totally removed Indy 8 from BCB6 according to instructions in
Indy's Knowledge Base before I installed 9.0.17.
New question.
I look at the demo program that wrote in Pascal, I'd try to convert it to
bcb6, refer to IdPorts. I want to listing port in combox. see code below,
TList *PortList;
PortList = IdPorts();
for (i=0; i< PortList->Count; i++)
{
cboPorts->Items->Add(PortList->Items[i]);
}
Warning: cannot convert void to AnsiString. I know PortList->Items[i] return
the object, But what object in side and How can I get port list?
Regards
Susan
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Jan 06, 2006 2:30 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | Where can I get the version 9.0.50?
|
The link to the Development Snapshot is on the same page as 9.0.17.
| Quote: | I read doc said TIdAntiFreeze can use to prevent User
Interface being frozen
|
That only applies to blocking operation that are performed in the context of
the main thread, which is the thread that controls the GUI.
| Quote: | if is little effect, then how to do?
|
You don't need to use TIdAntiFreeze with server components. Indy server
components are multi-threaded. Almost all server operations are performed
outside of the main thread.
| Quote: | I look at the demo program that wrote in Pascal
|
Which demo are you referring to? There are several different ones.
| Quote: | Warning: cannot convert void to AnsiString.
|
TList is a list of void* pointers. You cannot convert a void* pointer to a
string. The TList object that IdPorts() returns contains integer values
that are stored as void* pointers. Simply cast the pointers back to
integers, ie:
cboPorts->Items->Add(reinterpret_cast<int>(PortList->Items[i]));
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Fri Jan 06, 2006 9:29 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Very thanks.
| Quote: | The link to the Development Snapshot is on the same page as 9.0.17.
I went to Development Snapshot page and download Indy 9 and install in |
BCB6,it worked. but I cannot get the version number, only can see "Version
DevSnapshot", is it version 9.0.50?
New question
I wrote a server program that convert from Demo Pascal code and run on my
PC, but I cannot start server. If I run it by clicking F9, and set some
break point, it is very strange, the process will jump codes and go to the
end of function. see below code.
bool TfrmMain::StartServer()
{
TIdSocketHandle *Binding;
int i;
TStringList *SL ;
bool result, bChk;
result = false;
if (!StopServer())
{
fErrors->Append("Error stopping server");
result = false;
return result;
}
SL = new TStringList;
if (!SL) return false;
IdTCPServer->Bindings->Clear();
// bindings cannot be cleared until TidTCPServer is inactive
try
{
//=====================================================
// lbIPs is TCheckListBox that store two ip address
// 192.168.1.106
// 127.0.0.1
// I check 127.0.0.1 and select port number: 9999
//===================================================
for (i=0; i< lbIPs->Count-1; i++)
{
bChk = lbIPs->Checked[i];
if (bChk) // Cursor jump from here, below code not process
{
Binding = IdTCPServer->Bindings->Add();
Binding->IP = lbIPs->Items->Strings[i];
Binding->Port = StrToInt(edtPort->Text);
SL->Append("Server bound to IP " + Binding->IP + " on port "
+ edtPort->Text);
}
}
if (bChk) // Cursor jump from here, below code not process
{
IdTCPServer->Active = true;
result = IdTCPServer->Active;
fServerRunning = result;
lbProcesses->Items->AddStrings(SL);
if (result)
{
lbProcesses->Items->Append("Server started");
StatusBar->SimpleText = "Server running";
}
else
{
lbProcesses->Items->Append("Server stopped");
StatusBar->SimpleText = "Server stopped";
}
}
}
catch (Exception &exception)
{
lbProcesses->Items->Append("Server not started");
fErrors->Append(exception.Message);
result = false;
fServerRunning = result;
}
delete SL;
return result;
}
void __fastcall TfrmMain::btnStartServerClick(TObject *Sender)
{
int x,i;
x = 0;
for (i=0; i<lbIPs->Count; i++)
{
if (lbIPs->Checked[i])
x++;
}
if (x < 1)
{
ShowMessage("Cannot proceed until you select at least one IP to
bind!");
return;
}
fErrors->Clear();
if (!StartServer())
ShowMessage("Error starting servertt" + fErrors->CommaText);
else
ShowMessage("Server started successfully!");
}
run out of BCB, always get "Error starting server".
Please help, thanks.
Regards
Susan
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Jan 06, 2006 7:09 pm Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | I went to Development Snapshot page and download Indy 9
and install in BCB6,it worked. but I cannot get the version
number, only can see "Version DevSnapshot", is it version
9.0.50?
|
The version number is contained in IdVers.inc, and is also viewable when you
right-click on any Indy component at design-time.
| Quote: | I wrote a server program that convert from Demo Pascal code
and run on my PC, but I cannot start server.
|
According to the comments in your code, your loop through the TCheckListBox
is not seeing any checked items, so there are no values available to set up
the server with. Which makes sense because you are subtracting -1 from the
lbIP->Items->Count, so the loop never sees the last item in the list - which
is the "127.0.0.1" item that you are checking - and so the
IdTCPServer1->Bindings remain empty. In other words, you need to change
this line:
for (i=0; i< lbIPs->Count-1; i++)
To this instead:
for (i=0; i< lbIPs->Count; i++)
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Mon Jan 09, 2006 1:39 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Very thanks.
| Quote: | for (i=0; i< lbIPs->Count-1; i++)
To this instead:
for (i=0; i< lbIPs->Count; i++)
|
Sorry, that is my mistack.
But once I run the code below, I always got result = false, so I still
cannot start server. After that, I close my server app, I always got error
"Project server.exe raise exception class EAccessViolation with Message
'Access violation at address 40006834 .....", please help, thanks.
for (i=0; i< lbIPs->Count; i++)
{
bChk = lbIPs->Checked[i];
if (bChk)
{
Binding = IdTCPServer->Bindings->Add();
Binding->IP = lbIPs->Items->Strings[i];
Binding->Port = StrToInt(edtPort->Text);
SL->Append("Server bound to IP " + Binding->IP + " on port " +
edtPort->Text);
}
}
if (bChk)
{
IdTCPServer->Active = true;
result = IdTCPServer->Active; //result = false, seems cannot active
IdTCPServer
fServerRunning = result;
lbProcesses->Items->AddStrings(SL);
if (result)
{
lbProcesses->Items->Append("Server started");
StatusBar->SimpleText = "Server running";
}
else
{
lbProcesses->Items->Append("Server stopped");
StatusBar->SimpleText = "Server stopped";
}
}
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Jan 09, 2006 10:35 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | But once I run the code below, I always got result = false,
so I still cannot start server.
|
Your code is using the checked status of only the *last* item in the list to
decide whether to activate the server. If the last item is not checked,
your code ignores the activation altogether.
Try this code:
IdTCPServer->Active = false;
IdTCPServer->Bindings->Clear();
fServerRunning = false;
for(i = 0; i < lbIPs->Count; ++i)
{
if( lbIPs->Checked[i] )
{
Binding = IdTCPServer->Bindings->Add();
Binding->IP = lbIPs->Items->Strings[i];
Binding->Port = StrToInt(edtPort->Text);
//...
}
}
if( IdTCPServer->Bindings->Count > 0 )
{
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active;
}
//...
if( fServerRunning )
{
//...
}
else
{
//...
}
Result = fServerRunning;
//...
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Wed Jan 11, 2006 3:12 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Thanks.
I've modified my code according to your suggestion to void to ignores the
activation. But the server still cannot start, that means, call function
below:
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active;
fServerRunning always get false no matter you assign IdTCPServer->Active =
true or not.
What's matter?
I try Binding 127.0.0.1 or 192.168.1.106, both cannot, sometimes I got
Access Violation.
Any suggestion?
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jan 11, 2006 5:28 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | I've modified my code according to your suggestion to
void to ignores the activation. But the server still cannot
start, that means, call function below:
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active;
|
Then please show your latest code. The code I keep giving you works fine
for me, so you must not be copying it into your project correctly.
| Quote: | fServerRunning always get false no matter you assign
IdTCPServer->Active = true or not.
What's matter?
|
The only way setting the Active property to true can fail is if you have
provided invalid Binding values. But if that occured, you should be seeing
socket exceptions being thrown.
| Quote: | sometimes I got Access Violation.
|
Creating Bindings does not throw AVs. Where EXACTLY do the AVs occur in
your code? Please provide more details.
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Wed Jan 11, 2006 6:43 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Here is code I converted from pascal to BCB6.
Once I click on "Start" button, I got "Error starting server", I click
"Strat" button again, got "Access violation at address 40006834 in module
'rtl60.bpl". read of address....." or after "Error starting server", I close
application, also got acccess violation.
void __fastcall TfrmMain::FormCreate(TObject *Sender)
{
fErrors = new TStringList;
PopulateIPAddresses();
}
void TfrmMain::PopulateIPAddresses()
{
int i, port;
TList *PortList;
lbIPs->Clear();
lbIPs->Items = GStack->LocalAddresses;
lbIPs->Items->Add("127.0.0.1");
try
{
cboPorts->Items->Add("RSBindingAny");
cboPorts->Items->BeginUpdate();
PortList = IdPorts();
for (i=0; i< PortList->Count; i++)
{
port = reinterpret_cast<int>(PortList->Items[i]);
cboPorts->Items->Add(PortDescription(port));
}
}
__finally
{
cboPorts->Items->EndUpdate();
}
}
AnsiString TfrmMain::PortDescription(int PortNumber)
{
AnsiString Result;
TStrings *tStr;
Result = "";
tStr = GStack->WSGetServByPort(PortNumber);
if (tStr->Count > 0)
{
Result = AnsiString(PortNumber) + ": " + tStr->CommaText;
}
tStr->Free();
return Result;
}
//---------------------------------------------------------------------------
bool TfrmMain::StopServer()
{
bool Result;
IdTCPServer->Active = false;
IdTCPServer->Bindings->Clear();
Result = !IdTCPServer->Active;
fServerRunning = !Result;
if (Result)
{
StatusBar->SimpleText = "Server stopped";
lbProcesses->Items->Append("Server stopped");
}
else
{
StatusBar->SimpleText = "Server running";
lbProcesses->Items->Append("Server not stopped");
}
return Result;
}
bool TfrmMain::StartServer()
{
TIdSocketHandle *Binding;
int i;
TStringList *SL ;
bool result;
result = false;
if (!StopServer())
{
fErrors->Append("Error stopping server");
result = false;
return result;
}
SL = new TStringList;
if (!SL) return false;
IdTCPServer->Active = false;
IdTCPServer->Bindings->Clear();
fServerRunning = false;
try
{
for (i=0; i< lbIPs->Count; i++)
{
if( lbIPs->Checked[i] )
{
Binding = IdTCPServer->Bindings->Add();
Binding->IP = lbIPs->Items->Strings[i];
Binding->Port = StrToInt(edtPort->Text); //default 2222
SL->Append("Server bound to IP " + Binding->IP + " on port "
+ edtPort->Text);
}
}
if( IdTCPServer->Bindings->Count > 0 )
{
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active; //here always return
false
lbProcesses->Items->AddStrings(SL);
}
if( fServerRunning )
{
lbProcesses->Items->Append("Server started");
StatusBar->SimpleText = "Server running";
}
else
{
lbProcesses->Items->Append("Server stopped");
StatusBar->SimpleText = "Server stopped";
}
result = fServerRunning;
}
catch (Exception &exception)
{
lbProcesses->Items->Append("Server not started");
fErrors->Append(exception.Message);
result = false;
fServerRunning = result;
}
delete SL;
return result;
}
void __fastcall TfrmMain::btnStartServerClick(TObject *Sender)
{
int x,i;
x = 0;
for (i=0; i<lbIPs->Count; i++)
{
if (lbIPs->Checked[i])
x++;
}
if (x < 1)
{
ShowMessage("Cannot proceed until you select at least one IP to
bind!");
return;
}
fErrors->Clear();
if (!StartServer())
ShowMessage("Error starting servertt" + fErrors->CommaText);
else
ShowMessage("Server started successfully!");
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormDestroy(TObject *Sender)
{
if (fErrors)
delete fErrors;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::cboPortsChange(TObject *Sender)
{
AnsiString strPort;
int pos;
strPort = cboPorts->Items->Strings[cboPorts->ItemIndex];
pos = strPort.Pos(":");
if (pos > 0)
{
edtPort->Text = strPort.SubString(1,pos-1);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnStopServerClick(TObject *Sender)
{
fErrors->Clear();
if (!fServerRunning)
{
ShowMessage("Server it not running - no need to stop !");
return;
}
if (StopServer())
ShowMessage("Error stopping servertt" + fErrors->CommaText);
else
ShowMessage("Server stopped successfully");
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnClearMessagesClick(TObject *Sender)
{
lbProcesses->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::IdTCPServerExecute(TIdPeerThread *AThread)
{
AnsiString Command, tmpStr ;
Command = AThread->Connection->ReadLn();
Command = Command.UpperCase();
if (Command.AnsiCompare("TIME") == 0)
{
tmpStr = FormatDateTime("hh:nn:ss",Now());
AThread->Connection->WriteLn(tmpStr);
}
else if(Command.AnsiCompare("DATE") == 0)
{
tmpStr = FormatDateTime("dd/mmm/yyyy",Date());
AThread->Connection->WriteLn(tmpStr);
}
else if(Command.AnsiCompare("TICKCOUNT") == 0)
{
AThread->Connection->WriteInteger(GetTickCount());
}
else if (Command.AnsiCompare("QUIT") == 0)
{
AThread->Connection->WriteLn("Goodbye!");
AThread->Connection->Disconnect();
}
else
AThread->Connection->WriteLn("Command not recognised - try again!");
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::IdTCPServerConnect(TIdPeerThread *AThread)
{
AThread->Connection->WriteLn("Welcome to the Indy TCP basic
client/server demo");
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnExitClick(TObject *Sender)
{
Close();
}
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote
| Quote: |
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote in message
news:43c47703$1 (AT) newsgroups (DOT) borland.com...
I've modified my code according to your suggestion to
void to ignores the activation. But the server still cannot
start, that means, call function below:
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active;
Then please show your latest code. The code I keep giving you works fine
for me, so you must not be copying it into your project correctly.
fServerRunning always get false no matter you assign
IdTCPServer->Active = true or not.
What's matter?
The only way setting the Active property to true can fail is if you have
provided invalid Binding values. But if that occured, you should be
seeing
socket exceptions being thrown.
sometimes I got Access Violation.
Creating Bindings does not throw AVs. Where EXACTLY do the AVs occur in
your code? Please provide more details.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jan 11, 2006 10:17 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | Once I click on "Start" button, I got "Error starting server", I
click "Strat" button again, got "Access violation at address 40006834
in module 'rtl60.bpl". read of address....." or after "Error starting
server",
I close application, also got acccess violation.
|
Did you try debugging the code yet to find the EXACT lines where the errors
are occuring?
| Quote: | void __fastcall TfrmMain::FormCreate(TObject *Sender)
|
DO NOT use the OnCreate event in C++! It is a Delphi idiom that produces
illegal behavior in C++, as it can be triggered before the constructor is
called. Use the actual constructor instead. The same goes for the
OnDestroy event as well - it produces illegal behavior because it can be
triggered after the destructor is called.
Try the following code:
__fastcall TfrmMain::TfrmMain(TComponent *Owner)
: TForm(Owner)
{
fErrors = new TStringList;
PopulateIPAddresses();
}
__fastcall TfrmMain::~TfrmMain()
{
if( fErrors )
delete fErrors;
}
void TfrmMain::PopulateIPAddresses()
{
lbIPs->Items->Assign(GStack->LocalAddresses);
lbIPs->Items->Add("127.0.0.1");
cboPorts->Items->BeginUpdate();
try
{
cboPorts->Items->Add("RSBindingAny");
TList *PortList = IdPorts();
for(int i = 0; i < PortList->Count; ++i)
{
int port = reinterpret_cast<int>(PortList->Items[i]);
cboPorts->Items->Add(PortDescription(port));
}
}
__finally
{
cboPorts->Items->EndUpdate();
}
}
AnsiString TfrmMain::PortDescription(int PortNumber)
{
AnsiString Result;
// there is a bug in Indy 9's WSGetServByPort() that can return
// an invalid TStrings* pointer if a failure occurs internally...
TStrings *tStr = GStack->WSGetServByPort(PortNumber);
if( tStr )
{
try
{
try
{
if( tStr->Count > 0 )
Result = AnsiString(PortNumber) + ": " +
tStr->CommaText;
else
Result = PortNumber;
}
__finally
{
delete tStr;
}
}
catch(const Exception &)
{
Result = PortNumber;
}
}
return Result;
}
bool TfrmMain::StopServer()
{
IdTCPServer->Active = false;
fServerRunning = IdTCPServer->Active;
if( fServerRunning )
{
StatusBar->SimpleText = "Server running";
lbProcesses->Items->Append("Server not stopped");
}
else
{
StatusBar->SimpleText = "Server stopped";
lbProcesses->Items->Append("Server stopped");
}
return !fServerRunning;
}
bool TfrmMain::StartServer()
{
if( !StopServer() )
{
fErrors->Append("Error stopping server");
return false;
}
IdTCPServer->Bindings->Clear();
IdTCPServer->DefaultPort = StrToInt(edtPort->Text);
TStringList *SL = new TStringList;
try
{
try
{
for(int i = 0; i< lbIPs->Count; ++i)
{
if( lbIPs->Checked[i] )
{
TIdSocketHandle *Binding =
IdTCPServer->Bindings->Add();
Binding->IP = lbIPs->Items->Strings[i];
SL->Append("Server bound to IP " + Binding->IP + "
on port " + edtPort->Text);
}
}
if( IdTCPServer->Bindings->Count > 0 )
{
IdTCPServer->Active = true;
fServerRunning = IdTCPServer->Active;
}
if( fServerRunning )
{
lbProcesses->Items->AddStrings(SL);
lbProcesses->Items->Append("Server started");
StatusBar->SimpleText = "Server running";
}
else
{
lbProcesses->Items->Append("Server not started");
StatusBar->SimpleText = "Server stopped";
}
}
__finally
{
delete SL;
}
}
catch(const Exception &e)
{
IdTCPServer1->Active = false;
fServerRunning = IdTCPServer1->Active;
lbProcesses->Items->Append("Server not started");
fErrors->Append(e.Message);
}
return fServerRunning;
}
void __fastcall TfrmMain::btnStartServerClick(TObject *Sender)
{
for(int i = 0; i < lbIPs->Count; ++i)
{
if( lbIPs->Checked[i] )
{
fErrors->Clear();
if( !StartServer() )
ShowMessage("Error starting servertt" +
fErrors->CommaText);
else
ShowMessage("Server started successfully!");
return;
}
}
ShowMessage("Cannot proceed until you select at least one IP to
bind!");
}
void __fastcall TfrmMain::cboPortsChange(TObject *Sender)
{
int index = cboPorts->ItemIndex;
if( index > -1 )
{
AnsiString strPort = cboPorts->Items->Strings[index];
edtPort->Text = Fetch(strPort, ":");
}
}
void __fastcall TfrmMain::btnStopServerClick(TObject *Sender)
{
fErrors->Clear();
if( fServerRunning )
{
if( !StopServer() )
ShowMessage("Error stopping servertt" +
fErrors->CommaText);
else
ShowMessage("Server stopped successfully");
}
else
ShowMessage("Server it not running - no need to stop !");
}
void __fastcall TfrmMain::btnClearMessagesClick(TObject *Sender)
{
lbProcesses->Clear();
}
void __fastcall TfrmMain::IdTCPServerExecute(TIdPeerThread *AThread)
{
AnsiString Command = AThread->Connection->ReadLn();
if( AnsiSameText(Command, "TIME") )
{
AThread->Connection->WriteLn(Now().FormatString("hh:nn:ss"));
}
else if( AnsiSameText(Command, "DATE") )
{
AThread->Connection->WriteLn(Date().FormatString("dd/mmm/yyyy"));
}
else if( AnsiSameText(Command, "TICKCOUNT") )
{
AThread->Connection->WriteInteger(GetTickCount());
}
else if( AnsiSameText(Command, "QUIT") )
{
AThread->Connection->WriteLn("Goodbye!");
AThread->Connection->DisconnectSocket();
}
else
AThread->Connection->WriteLn("Command not recognised - try
again!");
}
void __fastcall TfrmMain::IdTCPServerConnect(TIdPeerThread *AThread)
{
AThread->Connection->WriteLn("Welcome to the Indy TCP basic
client/server demo");
}
void __fastcall TfrmMain::btnExitClick(TObject *Sender)
{
Close();
}
With that said, if you use the TIdTCPServer's Greeting and CommandHandlers
properties, you can get rid of the TIdTCPServer's OnExecute event handler
altogether. These properties can be configured at design-time to do much of
the run-time work automatically for you:
--- TfrmMain.cpp ---
void __fastcall TfrmMain::IdTCPServer1TimeCommand(TIdCommand *ASender)
{
ASender->Reply->SetReply(200, Now().FormatString("hh:nn:ss"));
}
void __fastcall TfrmMain::IdTCPServer1DateCommand(TIdCommand *ASender)
{
ASender->Reply->SetReply(200, Date().FormatString("dd/mmm/yyyy"));
}
void __fastcall TfrmMain::IdTCPServer1TickCountCommand(TIdCommand
*ASender)
{
ASender->Reply->SetReply(200, GetTickCount());
}
--- TfrmMain.dfm ---
...
object IdTCPServer1: TIdTCPServer
...
CommandHandlers = <
item
CmdDelimiter = ' '
Command = 'TIME'
Disconnect = False
Name = 'Time'
OnCommand = IdTCPServer1TimeCommand
ParamDelimiter = ' '
ReplyExceptionCode = 0
ReplyNormal.NumericCode = 200
Tag = 0
end
item
CmdDelimiter = ' '
Command = 'DATE'
Disconnect = False
Name = 'Date'
OnCommand = IdTCPServer1DateCommand
ParamDelimiter = ' '
ReplyExceptionCode = 0
ReplyNormal.NumericCode = 200
Tag = 0
end
item
CmdDelimiter = ' '
Command = 'TICKCOUNT'
Disconnect = False
Name = 'TickCount'
OnCommand = IdTCPServer1TickCountCommand
ParamDelimiter = ' '
ReplyExceptionCode = 0
ReplyNormal.NumericCode = 200
Tag = 0
end
item
CmdDelimiter = ' '
Command = 'QUIT'
Disconnect = True
Name = 'Quit'
ParamDelimiter = ' '
ReplyExceptionCode = 0
ReplyNormal.NumericCode = 200
ReplyNormal.Text.Strings = (
'Goodbye!')
Tag = 0
end>
...
Greeting.NumericCode = 200
Greeting.Text.Strings = (
'Welcome to the Indy TCP basic client/server demo')
...
ReplyExceptionCode = 500
...
ReplyUnknownCommand.NumericCode = 501
ReplyUnknownCommand.Text.Strings = (
'Command not recognised - try again!')
...
end
...
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Thu Jan 12, 2006 2:56 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Hi,
I've copied the full code you provided me to my server project, and try to
use TIdTCPServer's Greeting and CommandHandlers instead of OnExecute and
IdTCPServerConnect event. I use Object Inspector to create four
TidCommandHandler and assign event, one I compile got "E2293 ) expected".
here is ServerMain.h file
#ifndef ServerMainH
#define ServerMainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdTCPServer.hpp>
#include <CheckLst.hpp>
#include <IdAntiFreeze.hpp>
#include <IdAntiFreezeBase.hpp>
//---------------------------------------------------------------------------
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TPageControl *pgeMain;
TTabSheet *tabProcesses;
TTabSheet *tabMain;
TStatusBar *StatusBar;
TButton *btnStartServer;
TButton *btnStopServer;
TButton *btnExit;
TButton *btnClearMessages;
TCheckListBox *lbIPs;
TComboBox *cboPorts;
TEdit *edtPort;
TListBox *lbProcesses;
TLabel *Label1;
TIdTCPServer *IdTCPServer;
void __fastcall btnStartServerClick(TObject *Sender);
void __fastcall cboPortsChange(TObject *Sender);
void __fastcall btnStopServerClick(TObject *Sender);
void __fastcall btnClearMessagesClick(TObject *Sender);
void __fastcall IdTCPServerExecute(TIdPeerThread *AThread);
void __fastcall IdTCPServerConnect(TIdPeerThread *AThread);
void __fastcall btnExitClick(TObject *Sender);
void __fastcall IdTCPServerTimeCommand(TIdCommand *ASender); //"E2293 )
expected".
void __fastcall IdTCPServerDateCommand(TIdCommand *ASender); //"E2293 )
expected".
void __fastcall IdTCPServerTickCountCommand(TIdCommand *ASender);
//"E2293 ) expected".
private: // User declarations
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
__fastcall TfrmMain::~TfrmMain();
TStringList *fErrors;
bool fServerRunning;
void PopulateIPAddresses();
AnsiString PortDescription(int PortNumber);
bool StopServer();
bool StartServer();
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmMain *frmMain;
//---------------------------------------------------------------------------
#endif
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jan 12, 2006 4:43 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
"Liu Shan" <liushan (AT) ps-electronic (DOT) com> wrote
| Quote: | void __fastcall IdTCPServerExecute(TIdPeerThread *AThread);
void __fastcall IdTCPServerConnect(TIdPeerThread *AThread);
|
You did not get rid of the unused event handlers.
| Quote: | void __fastcall IdTCPServerTimeCommand(TIdCommand *ASender);
//"E2293 )
expected".
void __fastcall IdTCPServerDateCommand(TIdCommand *ASender);
//"E2293 )
expected".
void __fastcall IdTCPServerTickCountCommand(TIdCommand *ASender);
//"E2293 ) expected".
|
There is nothing wrong with those lines. There is no reason for compiler
errors to be occuring. Everything compiles and runs fine when I use the
code I gave you.
| Quote: | __fastcall TfrmMain::~TfrmMain();
|
Remove the class qualification
__fastcall ~TfrmMain();
Gambit
|
|
| Back to top |
|
 |
Liu Shan Guest
|
Posted: Thu Jan 12, 2006 5:36 am Post subject: Re: Unresolved external 'Idantifreeze::TIdAntiFreeze: |
|
|
Hi, very thanks.
"E2293 ) expected" assuredly happened on my BCB6, don't know why.
I try to get rid of these code and compile it, but once I run it, still got
"Error starting server", that means IdTCPServer->Active always return false,
thing goes back.
Good thing is that the "Access violation" didn't occur again.
Maybe my BCB6 has some problem or maybe Indy has, I decide to give up using
Indy in BCB6 until BDS2006 comes up.
Any way, very thanks for your fully support in a last few days.
Regards
Susan
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|