sockets.pp 2.2 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. {$i unxsockh.inc}
  19. {$i socketsh.inc}
  20. type
  21. TUnixSockAddr = packed Record
  22. {$ifdef SOCK_HAS_SINLEN}
  23. sa_len : cuchar;
  24. {$endif}
  25. family : sa_family_t;
  26. path:array[0..107] of char; //104 total for freebsd.
  27. end;
  28. { unix socket specific functions }
  29. Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var len:longint);
  30. Function Bind(Sock:longint;const addr:string):boolean;
  31. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:text):Boolean;
  32. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:file):Boolean;
  33. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:text):Boolean;
  34. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:File):Boolean;
  35. //function fpaccept (s:cint; addrx : psockaddr; addrlen : psocklen):cint; maybelibc
  36. //function fpbind (s:cint; addrx : psockaddr; addrlen : tsocklen):cint; maybelibc
  37. //function fpconnect (s:cint; name : psockaddr; namelen : tsocklen):cint; maybelibc
  38. Implementation
  39. Uses BaseUnix,{$ifndef FPC_USE_LIBC}SysCall{$else}initc{$endif};
  40. { Include filerec and textrec structures }
  41. {$i filerec.inc}
  42. {$i textrec.inc}
  43. {******************************************************************************
  44. Kernel Socket Callings
  45. ******************************************************************************}
  46. {$ifndef FPC_USE_LIBC}
  47. {$i unixsock.inc}
  48. {$else}
  49. {$i stdsock.inc}
  50. {$endif}
  51. {$i sockovl.inc}
  52. {$i sockets.inc}
  53. end.