2
0

sockets.pp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 baseunix,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. const
  32. EsockEINTR = EsysEINTR;
  33. EsockEBADF = EsysEBADF;
  34. EsockEFAULT = EsysEFAULT;
  35. EsockEINVAL = EsysEINVAL;
  36. EsockEACCESS = ESysEAcces;
  37. EsockEMFILE = ESysEmfile;
  38. EsockEMSGSIZE = ESysEMsgSize;
  39. EsockENOBUFS = ESysENoBufs;
  40. EsockENOTCONN = ESysENotConn;
  41. EsockENOTSOCK = ESysENotSock;
  42. EsockEPROTONOSUPPORT = ESysEProtoNoSupport;
  43. EsockEWOULDBLOCK = ESysEWouldBlock;
  44. { unix socket specific functions }
  45. Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var len:longint); deprecated;
  46. Function Bind(Sock:longint;const addr:string):boolean; deprecated;
  47. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:text):Boolean; deprecated;
  48. Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:file):Boolean; deprecated;
  49. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:text):Boolean; deprecated;
  50. Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:File):Boolean; deprecated;
  51. //function fpaccept (s:cint; addrx : psockaddr; addrlen : psocklen):cint; maybelibc
  52. //function fpbind (s:cint; addrx : psockaddr; addrlen : tsocklen):cint; maybelibc
  53. //function fpconnect (s:cint; name : psockaddr; namelen : tsocklen):cint; maybelibc
  54. Implementation
  55. Uses {$ifndef FPC_USE_LIBC}SysCall{$else}initc{$endif};
  56. threadvar internal_socketerror : cint;
  57. { Include filerec and textrec structures }
  58. {$i filerec.inc}
  59. {$i textrec.inc}
  60. {******************************************************************************
  61. Kernel Socket Callings
  62. ******************************************************************************}
  63. function socketerror:cint;
  64. begin
  65. socketerror:=internal_socketerror;
  66. end;
  67. {$ifndef FPC_USE_LIBC}
  68. {$i unixsock.inc}
  69. {$else}
  70. {$i stdsock.inc}
  71. {$endif}
  72. {$i sockovl.inc}
  73. {$i sockets.inc}
  74. end.