Recent

Author Topic: [SOLVED] Up to date documentation?  (Read 416 times)

RastaManKing

  • New member
  • *
  • Posts: 13
[SOLVED] Up to date documentation?
« on: November 28, 2018, 01:01:19 am »
a little background:
i have been programing in C#, Java, and Delphi, under windows.
i tried lazarus before but due to "commodity" i fell back to delphi.
but now i have finally made the switch, from windows to linux,
and im making a full switch lo leave close source as much as i can,
im determined to leave C# and Delphi for freepascal/lazarus.

the culprit:
i have a personal project(C#) where i make use of raw sockets,
i want to rewrite this project in freepascal with lazarus, but this time with a datagram socket.
i managed to write most of my networking unit but i get many "deprecated" warnings and other troubles,
for example on "NetToHost" and getting sockaddr_in instead of just sockaddr, etc..
i get all my information from " official" documentation along with their examples but i have
noticed that the vast majority if not all on there seems outdated.
https://www.freepascal.org/docs-html/rtl/sockets/index-5.html
also in lazarus wiki the sockets unit sections has a bold sentence saying its deprecated.

my question:
i wonder if anyone could share with me an up to date documentation?
im mainly looking for sockets unit documentation that is up to date and avoid 3rd parties.
also i would like to understand, for example in C# sockets are of the "socket" type
and the buffers/data is of "byte" type, but in freepascal im seeing that sockets are of "LongInt" type
and buffers are of "String" type.. this puzzles me somewhat.
thank you!



PS:
from simple mortals like me to everyone that keeps freepascal, lazarus, and this forums alive... A WORLD OF THANKS!!!
« Last Edit: November 28, 2018, 05:41:28 pm by RastaManKing »

sash

  • Full Member
  • ***
  • Posts: 158
Re: Up to date documentation?
« Reply #1 on: November 28, 2018, 11:16:06 am »
in C# sockets are of the "socket" type ..., but in freepascal im seeing that sockets are of "LongInt" type

I just guess FPC's socket is a handle, while C#'s one is a wrapper/class.
Lazarus 1.8.4 Unversioned directory FPC 3.0.4 x86_64-linux-gtk2 -- Ubuntu 18.04 XFCE

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 833
    • Burdjia
Re: Up to date documentation?
« Reply #2 on: November 28, 2018, 11:19:22 am »
AFAIK you can use the documentation for C.  FreePascal's RTL just wraps the same libraries than GCC C/C++ compiler.  Just pay attention to the type names (i.e. C's "char" is "SHORTINT" in Pascal, "float" is "SINGLE", etc.).  You can use unit ctype too.

[edit]
Almost the same sash said.
« Last Edit: November 28, 2018, 11:22:06 am by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6617
Re: Up to date documentation?
« Reply #3 on: November 28, 2018, 12:15:28 pm »
In Pascal you have both high level object wrapper access (the so called socket suites like Indy and LNET, some of which are additional installs), and direct access to the (BSD) socket functions like in other lowlevel languages.

Sockets are indeed a kind of handles and in practice 32-bit integers. Buffers are typically pointers to memory that you must allocate/manage. The core read and write functions are fprecv and fpsend, the rest are utility functions.

The hosttonet functions are 1.0.x level functions and deprecated.  In 2005 they were replaced by more standardized htons/l like functions, so better use those for new code
« Last Edit: November 28, 2018, 12:19:18 pm by marcov »

RastaManKing

  • New member
  • *
  • Posts: 13
Re: Up to date documentation?
« Reply #4 on: November 28, 2018, 05:40:45 pm »
thank you all for the information provided, it did help clear things up for me, im starting to realize c# is a bunch of wrappers for everything,
i will just have to get used to work with handles now, its not much different i think :)

for anyone else interested i found good documentation on linux sockets
http://man7.org/linux/man-pages/man7/ip.7.html