User talk:MarkMLl

From Free Pascal wiki
Jump to navigationJump to search
  #############################################################################
 #      1         2         3         4         5         6         7         8
# 45678901234567890123456789012345678901234567890123456789012345678901234567890
#
#    Degrees in electronics, ex-B, ex-LUT, ex-GM.
#    Not married, no children, does not live in East Sussex.
#
#    See User:MarkMLl tab (above) for more info.
#
###############################################################################

Useful links

Free Pascal manuals

Reference for package 'rtl'


Notes to self

This is all stuff that I'll try to fold into the documentation when I'm more confident.

Sockets programming

Matthias tells me that for portability low-level sockets programming should be done via sockets.pp.

My own experience is that under Win-32 one has to use winsock since otherwise there's no select(). In general winsock compatibility between Delphi and Lazarus under Win-32 appears to be good.

When code is ported to Linux one ends up using sockets (for sockets-specific stuff), baseunix (for select() and supporting procedures) and unix (for gethostname()). Some functions/procedures need to be prefixed by fp, e.g. fpFD_SET(), fpselect() etc. (thanks Marco for pointing that out). Some functions with the fp prefix expect a pointer to (for example) a sockaddr rather than passing it by reference, in general the compiler will catch all of these.

What the compiler won't catch is that the first parameter to select() (AKA fpselect()) varies across platforms. Win-32 winsock documents it as being unused, some texts describe it as "the number of file descriptors in the set". THIS IS AMBIGUOUS. The first parameter to select() under unix is the highest file descriptor that needs to be checked in the bitsets passed as the 2nd, 3rd and 4th parameters, if a single socket is to be checked this will normally have the numeric value of the socket/handle plus one:



Hence a safe default for the parameter to select is not 1, it is the number of bits in the set which winsock defines as FD_SETSIZE (typically = 64) and which FPC under unix apparently defines as FD_MAXFDSET. In case where for some reason this is not defined under unix it might defer to the same number of file handles that may be opened per-process. Setting this too small under unix risks not checking a filehandle of interest, setting it too large might be inefficient and might have undesired effects if it exceeds the number of bits in a TFDSET: if in doubt it's probably best to use 8 * SizeOf(TFDSET).

I notice that fpFD_SET() returns an integer, I've not checked yet to see what this represents: it would be convenient if it was the highest bit set as discussed above.

zSeries

Somebody's already references a (non-existant) ZSeries page, so I've created it with some thoughts and links based on my limited experience with the Hercules emulator and related research.

MIPS

Itanium

If I manage to get my hands on one of these I'll try to add anything that might be useful. In the interim [1] is a useful "warts and all" discussion of systems programming for this brute.

SPARC Solaris