Hello, Matthew! Hi, everybody!
According to RHS Linux User:
I was trying to open a socket, but the problem I kept running into was that connect wants a sockaddr struct, and in C you just casted it... (struct sockaddr *)&address but, I don't think that that is possible in pascal, [...]
Since you cannot simply #include a C header file in a Pascal program you have to define the type by yourself:
Const AF_UNSPEC = 0; AF_UNIX = 1; (* Unix domain sockets *) AF_INET = 2; (* Internet IP Protocol *) AF_AX25 = 3; (* Amateur Radio AX.25 *) AF_IPX = 4; (* Novell IPX *) AF_APPLETALK = 5; (* Appletalk DDP *) AF_NETROM = 6; (* Amateur radio NetROM *) AF_BRIDGE = 7; (* Multiprotocol bridge *) AF_AAL5 = 8; (* Reserved for Werner's ATM *) AF_X25 = 9; (* Reserved for X.25 project *) (*$ifdef LINUX_2_1_X *) AF_INET6 = 10; (* IP version 6 *) (*$endif *) AF_MAX = 12; (* For now.. *)
Type SockAddrPtr = ^SockAddr; SockAddr = record case family: ShortCard of AF_UNSPEC: ( data: packed array [ 0..13 ] of Char ); AF_INET: ( port: ShortWord; address: array [ 1..4 ] of Byte ); end (* SockAddr *);
Having this you can declare a variable `Address' of type `SockAddr', so `@Address' will have the correct type - no need to cast. However, `SockAddrPtr ( @Address )' is the exact analogon of your C fragment above.
Hope this helps,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [971005] maintainer GNU Pascal [971001] - http://home.pages.de/~gnu-pascal/ [971005]