Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-03

Socket (Depecrated) on FreePascal

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Diego Antonio Lucena Pumar

Hi List:

My name is Diego and write from Spain. I need help. My problem resist on the primitive deprecated Accept. The interface is the following:

function Accept(
  Sock: LongInt;
  var Addr;
  var Addrlen: LongInt
):LongInt;

For my program I need use this interface, and not the modern versions.

Really, I can't compile the program. The error is provacated by the parameter (var Addr;). In the documentation y can read about this type of argument and indicated that is trated of Variable parameters. I read more and opine that this argument need a reference to a structure INADDR. But a call the function this:

Saux := Accept(S1, @Addr, sizeof(Addr));

Where:

S1: is socket descriptor.
Addr; is a variable type TInetSockAddr.

What is my error?. Sorry for my english. Thanks.

Jonas Maebe
to Diego Antonio Lucena Pumar
Diego Antonio Lucena Pumar wrote 19 lines
function Accept( Sock: LongInt; var Addr; var Addrlen: LongInt ):LongInt; For my program I need use this interface, and not the modern versions. Really, I can't compile the program. The error is provacated by the parameter (var Addr;). In the documentation y can read about this type of argument and indicated that is trated of Variable parameters. I read more and opine that this argument need a reference to a structure INADDR. But a call the function this: Saux := Accept(S1, @Addr, sizeof(Addr));

In Pascal, "var" parameters implicitly take the address of the argument you pass. So if you pass @Addr, the compiler will try to take the address of "@Addr", which does not make sense (you cannot take the address of an address). So instead, just pass Addr.

Jonas