See solution below: > On 6/15/2014 6:08 PM, m...@rpzdesign.com wrote: >> I was looking through the RTL and found that cfprecvmsg( ) socket calls >> into the C Run Time library were commented out. >> >> Also commented out cfpsendmsg( ) calls. >> >> While recvfrom( ) is available, it does not include the PTKINFO options >> necessary to determine a destination IP address on a multi interface >> Linux server. >> >> Nor does it offer the ability to set the Source Address when sending via >> sendto( ) >> >> Anybody have a quick suggestion or must I spend the afternoon >> implementing cfprecvmsg( ) and cfpsendmsg( ) calls. >> >> Thanks, >> >> Marco >> >> _______________________________________________ >> fpc-pascal maillist - fpc-pascal@lists.freepascal.org >> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal >> > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > On 6/15/2014 6:26 PM, m...@rpzdesign.com wrote:> Ok, I am getting closer. > > Under the unixsockets in RTL, it has all the declarations necessary. > > Anybody have an idea on how to use unixsockets in a uses clause > so the compiler will not trigger: > > Can't find unit 'unixsockets' used by xxxx.pas > > Or should I just add the RTL to my project path? > > Thanks for any responses, > > marco > > >
It borrows heavily from RTL, but is now confirmed to work on Linux 2.6.x + Sorry to pepper the list... Here is the solution: A copied unixsockets file usable in fpc 2.6.4/lazarus 1.2.x unit fpunixsocket; {$mode objfpc}{$H+} {$packrecords C} interface uses sockets, cTypes, BaseUnix; type Piovec = ^Tiovec; Tiovec = record iov_base : pointer; iov_len : size_t; end; Pmsghdr = ^Tmsghdr; Tmsghdr = record msg_name : pointer; //8 msg_namelen : socklen_t; //4 msg_iov : piovec; //8 msg_iovlen : size_t; //8 msg_control : pbyte ; //8 msg_controllen : size_t; //8 msg_flags : cInt; //4 end; Pcmsghdr = ^Tcmsghdr; Tcmsghdr = record cmsg_len : size_t; cmsg_level : cInt; cmsg_type : cInt; end; Ppktinfo = ^Tpktinfo; Tpktinfo = record ipi_ifindex : longint; ipi_spec_dst : in_addr; ipi_addr : in_addr; end; function fpsendmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external 'c' name 'sendmsg'; function fprecvmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external 'c' name 'recvmsg'; function __cmsg_nxthdr(__mhdr:Pmsghdr; __cmsg:Pcmsghdr):Pcmsghdr;cdecl;external 'c' name '__cmsg_nxthdr'; function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr; function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr; function CMSG_ALIGN(len: size_t): size_t; function CMSG_SPACE(len: size_t): size_t; function CMSG_LEN(len: size_t): size_t; function CMSG_DATA(cmsg: Pcmsghdr): Pointer; implementation function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr; begin if mhdr^.msg_controllen >= SizeOf(Tcmsghdr) then Result:=Pointer(mhdr^.msg_control) else Result:=nil; end; function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr; begin Result:=__cmsg_nxthdr(mhdr, cmsg); end; function CMSG_ALIGN(len: size_t): size_t; begin Result:=(len+SizeOf(size_t)-1) and (not(SizeOf(size_t)-1)); end; function CMSG_SPACE(len: size_t): size_t; begin Result:=CMSG_ALIGN(len)+CMSG_ALIGN(SizeOf(Tcmsghdr)); end; function CMSG_LEN(len: size_t): size_t; begin Result:=CMSG_ALIGN(SizeOf(Tcmsghdr))+len; end; function CMSG_DATA(cmsg: Pcmsghdr): Pointer; begin Result:=Pointer( cuint64(cmsg) + SizeOf(Tcmsghdr)); end; end. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal