- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI want to use servent record in my application.
I declare Alias : PPChar;, but after calling getservbyname function when I try to get the value for s_aliases member I get a "Incompatible types : PPChar and Pointer " error message.
The funny thing is that if I write something in Project-> Options -> Build Events -> Pre-build commands the project compiles just fine.... (By saying something I don't mean something meaningful .. any blabla will do the job )
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: rllibbyPosted on 2008-12-17 at 10:19:56ID: 23196275
Try casting as PPChar(...). Eg, the following code compiles and tests correctly for D5.
PChar(Prot ocolName)) ; ; ort)])); ; // Cast pointer to desired type tLastError )]));
Regards,
Russell
// used "80 tcp"
program test;
{$APPTYPE CONSOLE}
uses
Dialogs,
SysUtils,
Winsock;
const
WSVersion: Word = $101;
type
PPChar = ^PChar;
var
WSAData: TWSAData;
Servent: PServent;
ProtocolName: String;
Alias: PPChar;
Port, ServiceCount: Integer;
begin
Port := 0;
if ParamCount < 2 then begin
WriteLn('Error - missing service port or protocol! '+#10#13+'Please supply a service name and protocol (e.g. 21 tcp');
Halt;
end;
try
Port := StrToInt(ParamStr(1));
except on EConvertError do begin
WriteLn(Format('Invalid Port %d',[Port]));
Halt;
end;
end;
ProtocolName := ParamStr(2);
if WSAStartUp(WSVersion, WSAData) = 0 then
begin
try
Servent := getservbyport(htons(Port),
if Servent <> NIL then
begin
WriteLn(Format('Official Service Name is %s',[Servent^.s_name]));
WriteLn(Format('Service Port is %d in network order',[Servent^.s_port]))
WriteLn(Format('Service Port is %d in host order',[ntohs(Servent^.s_p
WriteLn(Format('Protocol is %s',[Servent^.s_proto]));
ServiceCount := 0;
Alias := PPCHar(Servent^.s_aliases)
while Alias^ <> nil do begin
Inc(ServiceCount);
WriteLn(Format('Service Name [%d] is %s',[ServiceCount, Alias^]));
Inc(Alias);
end;
if ServiceCount = 0 then
WriteLn('None');
end
else
WriteLn(Format('Call to getservbyport() failed with error: %s',[SysErrorMessage(WSAGe
finally
WSACleanUp;
end;
end
else
WriteLn('Failed to load Winsock.');
end.