[fpc-pascal]winsock telnet proxy question #1

ron wilson ron.wilson at coastgames.com
Wed Mar 13 19:15:25 CET 2002

thanks - i just tried that and it works great.  you just have to change one
thing, but i'm not sure why the change works.  i think it has to do with the
h_addr definition as ^pchar, but i'm not sure.  i did this:

   move(server.h_addr^, serv_addr.sin_addr.s_addr, server.length);

also, this gives s_addr in network byte order, so you have to add this line
if you need host byte order:

   serv_addr.sin_addr.s_addr := htonl(serv_addr.sin_addr.s_addr);

here's my function, with old method commented out:

   function pchar_to_ulong(s: pchar): u_long;
   //i: u_short;
     rslt: u_long;
   //for i:=0 to min(sizeof(s),4)-1 do
   //  rslt+=u_long(s[i]) shl ((3-i)*8);

ron wilson.

-----Original Message-----
From: fpc-pascal-admin at deadlock.et.tudelft.nl
[mailto:fpc-pascal-admin at deadlock.et.tudelft.nl]On Behalf Of Marco van
de Voort
Sent: Wednesday, March 13, 2002 12:35 AM
To: fpc-pascal at deadlock.et.tudelft.nl
Subject: Re: [fpc-pascal]winsock telnet proxy question #1

> after that, i had to figure out what the C bcopy() command did and reverse
> engineer it.  i don't think freepascal has one of those.  or maybe it
> does... can anybody tranlsate this line into freepascal for me?  all the
> type-casting got me lost in fp.
>   bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr,
> server->h_length);

bcopy is afaik simply move, just with pointers as arguments, since C has
no open arrays as params.

> note: server->h_addr is ^pchar and serv_addr.sin_addr.s_addr is u_long.

Afaik it is simply:

move (server.h_addr,serv_addr.sin_addr.s_addr,server.length);

fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list