sockets.pp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. unit Sockets;
  11. Interface
  12. {$ifdef Unix}
  13. Uses UnixType;
  14. {$endif}
  15. {$ifdef FreeBSD}
  16. {$DEFINE SOCK_HAS_SINLEN} // BSD definition of scoketaddr
  17. {$endif}
  18. {$ifdef Darwin}
  19. {$DEFINE SOCK_HAS_SINLEN} // BSD definition of scoketaddr
  20. {$endif}
  21. {$i unxsockh.inc}
  22. {$i socketsh.inc}
  23. type
  24. TUnixSockAddr = packed Record
  25. {$ifdef SOCK_HAS_SINLEN}
  26. sa_len : cuchar;
  27. {$endif}
  28. family : sa_family_t;
  29. path:array[0..107] of char; //104 total for freebsd.
  30. end;
  31. { unix socket specific functions }
  32. Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var len:longint);
  33. Function Bind(Sock:longint;const addr:string):boolean;
  34. //function fpaccept (s:cint; addrx : psockaddr; addrlen : psocklen):cint; maybelibc
  35. //function fpbind (s:cint; addrx : psockaddr; addrlen : tsocklen):cint; maybelibc
  36. //function fpconnect (s:cint; name : psockaddr; namelen : tsocklen):cint; maybelibc
  37. Implementation
  38. Uses BaseUnix,{$ifndef FPC_USE_LIBC}SysCall{$else}initc{$endif};
  39. { Include filerec and textrec structures }
  40. {$i filerec.inc}
  41. {$i textrec.inc}
  42. {******************************************************************************
  43. Kernel Socket Callings
  44. ******************************************************************************}
  45. {$ifndef FPC_USE_LIBC}
  46. {$i unixsock.inc}
  47. {$else}
  48. {$i stdsock.inc}
  49. {$endif}
  50. {$i sockovl.inc}
  51. {$i sockets.inc}
  52. end.