sockets.pp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.10 2004-12-21 09:48:14 michael
  58. + Removed maybelibc macro
  59. Revision 1.9 2004/03/16 18:03:37 marco
  60. * first changes sockets units
  61. Revision 1.8 2003/11/25 15:13:28 marco
  62. * somebody added fields to socketsh.inc that were already under ifdef bsd
  63. Revision 1.7 2003/09/14 20:15:01 marco
  64. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  65. Revision 1.6 2002/09/07 16:01:27 peter
  66. * old logs removed and tabs fixed
  67. }