Thread View: borland.public.cppbuilder.internet.socket
18 messages
18 total messages
Started by Liu Shan
Thu, 05 Jan 2006 09:54
Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Thu, 05 Jan 2006 09:54
Date: Thu, 05 Jan 2006 09:54
12 lines
1455 bytes
1455 bytes
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_TEST\INDY\CLIENTSERVER\SERVERMAIN.OBJ Can anybody tell me how to solve this problem? Very thanks. Susan
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Thu, 05 Jan 2006 18:05
Date: Thu, 05 Jan 2006 18:05
25 lines
1763 bytes
1763 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message news:43bcec76$1@newsgroups.borland.com... > 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. > 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. > once I build it, I got : > [Linker Error] Unresolved external 'Idantifreeze::TIdAntiFreeze::' > referenced from F:\BCB6_TEST\INDY\CLIENTSERVER\SERVERMAIN.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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Fri, 06 Jan 2006 01:47
Date: Fri, 06 Jan 2006 01:47
48 lines
2787 bytes
2787 bytes
Hi,
Very thanks for your reply.
> 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.
> 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?
>> once I build it, I got :
>> [Linker Error] Unresolved external 'Idantifreeze::TIdAntiFreeze::'
>> referenced from F:\BCB6_TEST\INDY\CLIENTSERVER\SERVERMAIN.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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Fri, 06 Jan 2006 02:30
Date: Fri, 06 Jan 2006 02:30
35 lines
2115 bytes
2115 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message
news:43bdcbd3$1@newsgroups.borland.com...
> Where can I get the version 9.0.50?
The link to the Development Snapshot is on the same page as 9.0.17.
> 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.
> 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.
> I look at the demo program that wrote in Pascal
Which demo are you referring to? There are several different ones.
> 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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Fri, 06 Jan 2006 09:29
Date: Fri, 06 Jan 2006 09:29
125 lines
4511 bytes
4511 bytes
Very thanks.
> 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 server\t\t" + fErrors->CommaText);
else
ShowMessage("Server started successfully!");
}
run out of BCB, always get "Error starting server".
Please help, thanks.
Regards
Susan
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Fri, 06 Jan 2006 19:09
Date: Fri, 06 Jan 2006 19:09
31 lines
2216 bytes
2216 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message
news:43be37e8@newsgroups.borland.com...
> 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.
> 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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Mon, 09 Jan 2006 01:39
Date: Mon, 09 Jan 2006 01:39
48 lines
2513 bytes
2513 bytes
Very thanks.
> 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";
}
}
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Mon, 09 Jan 2006 10:35
Date: Mon, 09 Jan 2006 10:35
51 lines
2339 bytes
2339 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message
news:43c1be5a$1@newsgroups.borland.com...
> 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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Wed, 11 Jan 2006 03:12
Date: Wed, 11 Jan 2006 03:12
16 lines
1743 bytes
1743 bytes
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?
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Wed, 11 Jan 2006 05:28
Date: Wed, 11 Jan 2006 05:28
28 lines
2176 bytes
2176 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message news:43c47703$1@newsgroups.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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Wed, 11 Jan 2006 06:43
Date: Wed, 11 Jan 2006 06:43
307 lines
9256 bytes
9256 bytes
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 server\t\t" + 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 server\t\t" + 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@no.spam.com> wrote in message
news:43c496ed$1@newsgroups.borland.com...
>
> "Liu Shan" <liushan@ps-electronic.com> wrote in message
> news:43c47703$1@newsgroups.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
>
>
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Wed, 11 Jan 2006 10:17
Date: Wed, 11 Jan 2006 10:17
359 lines
11811 bytes
11811 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message
news:43c4a871@newsgroups.borland.com...
> 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?
> 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 server\t\t" +
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 server\t\t" +
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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Thu, 12 Jan 2006 02:56
Date: Thu, 12 Jan 2006 02:56
72 lines
3974 bytes
3974 bytes
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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Thu, 12 Jan 2006 04:43
Date: Thu, 12 Jan 2006 04:43
30 lines
2201 bytes
2201 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message
news:43c5c4ea@newsgroups.borland.com...
> void __fastcall IdTCPServerExecute(TIdPeerThread *AThread);
> void __fastcall IdTCPServerConnect(TIdPeerThread *AThread);
You did not get rid of the unused event handlers.
> 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.
> __fastcall TfrmMain::~TfrmMain();
Remove the class qualification
__fastcall ~TfrmMain();
Gambit
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Liu Shan
Date: Thu, 12 Jan 2006 05:36
Date: Thu, 12 Jan 2006 05:36
18 lines
2009 bytes
2009 bytes
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
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Thu, 12 Jan 2006 05:51
Date: Thu, 12 Jan 2006 05:51
26 lines
2391 bytes
2391 bytes
"Liu Shan" <liushan@ps-electronic.com> wrote in message news:43c5ea4b@newsgroups.borland.com... > "E2293 ) expected" assuredly happened on my BCB6, don't know why. Then I do not know what to tell you. It works fine for me. Please post your project to the "borland.public.attachments" newsgroup. > I try to get rid of these code and compile it, but once I run it, still > got "Error starting server" Everything works fine for me. > that means IdTCPServer->Active always return false Given the code you have shown, that should not be possible. If you set the Active property to true, then unless an exception was thrown, reading the Active property immediately afterwards is guaranteed to return true. > I decide to give up using Indy in BCB6 until BDS2006 comes up. You will end up using the same version of Indy 9 in BDS. Gambit
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Bob Gonder
Date: Thu, 12 Jan 2006 15:42
Date: Thu, 12 Jan 2006 15:42
8 lines
1757 bytes
1757 bytes
Liu Shan wrote: > void __fastcall IdTCPServerTimeCommand(TIdCommand *ASender); //"E2293 ) >expected". That usually means it doesn't know what a TIdCommand is. It might be missing from your headers, or maybe in a different namespace?
Re: Unresolved external 'Idantifreeze::TIdAntiFreeze:
Author: Remy Lebeau (TeamB)
Date: Thu, 12 Jan 2006 19:35
Date: Thu, 12 Jan 2006 19:35
13 lines
1798 bytes
1798 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:52ucs11atauf1sv98va99ephk5gejeoadm@4ax.com... > That usually means it doesn't know what a TIdCommand is. > It might be missing from your headers, or maybe in a different > namespace? In this case, since Lui is using Indy 9, TIdCommand is declared in IdTCPServer.hpp, which is already included in the code Lui showed. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads