sockets.pp 2.3 KB

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