sockets.pp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. {$macro on}
  17. {$DEFINE FPC_NEW_SOCKETS_UNIT}
  18. {$ifdef FPC_USE_LIBC}
  19. { define maybelibc:=cdecl;external;} // in future. Have to wrap now
  20. {$endif} // because of !@$!@#% socketerror
  21. {$define maybelibc:=}
  22. {$i unxsockh.inc}
  23. {$i socketsh.inc}
  24. type
  25. TUnixSockAddr = packed Record
  26. {$ifdef SOCK_HAS_SINLEN}
  27. sa_len : cuchar;
  28. {$endif}
  29. family : sa_family_t;
  30. path:array[0..107] of char; //104 total for freebsd.
  31. end;
  32. { unix socket specific functions }
  33. Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var len:longint);
  34. Function Bind(Sock:longint;const addr:string):boolean;
  35. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:text):Boolean;
  36. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:file):Boolean;
  37. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:text):Boolean;
  38. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:File):Boolean;
  39. //function fpaccept (s:cint; addrx : psockaddr; addrlen : psocklen):cint; maybelibc
  40. //function fpbind (s:cint; addrx : psockaddr; addrlen : tsocklen):cint; maybelibc
  41. //function fpconnect (s:cint; name : psockaddr; namelen : tsocklen):cint; maybelibc
  42. Implementation
  43. Uses BaseUnix,{$ifndef FPC_USE_LIBC}SysCall{$else}initc{$endif};
  44. { Include filerec and textrec structures }
  45. {$i filerec.inc}
  46. {$i textrec.inc}
  47. {******************************************************************************
  48. Kernel Socket Callings
  49. ******************************************************************************}
  50. {$ifndef FPC_USE_LIBC}
  51. {$i unixsock.inc}
  52. {$else}
  53. {$i stdsock.inc}
  54. {$endif}
  55. {$i sockovl.inc}
  56. {$i sockets.inc}
  57. end.
  58. {
  59. $Log$
  60. Revision 1.9 2004-03-16 18:03:37 marco
  61. * first changes sockets units
  62. Revision 1.8 2003/11/25 15:13:28 marco
  63. * somebody added fields to socketsh.inc that were already under ifdef bsd
  64. Revision 1.7 2003/09/14 20:15:01 marco
  65. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  66. Revision 1.6 2002/09/07 16:01:27 peter
  67. * old logs removed and tabs fixed
  68. }