home *** CD-ROM | disk | FTP | other *** search
/ Internet Standards / CD1.mdf / winsock / winsock.pas < prev    next >
Pascal/Delphi Source File  |  1993-02-13  |  8KB  |  163 lines

  1. unit WINSOCK;
  2.  
  3. { Winsock.h file for Borland Pascal
  4.   Conversion by Marc B. Manza
  5.              Center for Applied Large-Scale Computing
  6.   Requires Winsock.pas and Winsock.inc
  7.  
  8.   Send any comments/change requests/etc. to:
  9.   manza@flash.poly.edu }
  10.  
  11. interface
  12.  
  13. uses WIN31, WinTypes, WinProcs;
  14.  
  15. {$I winsock.inc }
  16.  
  17. { Library Functions }
  18.  
  19.   function accept (s : SOCKET; addr : sockaddr; addrlen : integer) : SOCKET;
  20.   function bind (s : SOCKET; addr : sockaddr; namelen : integer) : integer;
  21.   function closesocket (s : SOCKET) : integer;
  22.   function connect (s : SOCKET; name : sockaddr; namelen : integer) : integer;
  23.   function ioctlsocket (s : SOCKET; cmd : longint; argp : u_long) : integer;
  24.   function getpeername (s : SOCKET; name : sockaddr; namelen : integer) : integer;
  25.   function getsockname (s : SOCKET; name : sockaddr; namelen : integer) : integer;
  26.   function getsockopt (s : SOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  27.   function htonl (hostlong : u_long) : u_long;
  28.   function htons (hostshort : u_short) : u_short;
  29.   function inet_addr (cp : PChar) : PIn_Addr;  { in_addr }
  30.   function inet_ntoa (inaddr : in_addr) : PChar;
  31.   function listen (s : SOCKET; backlog : integer) : integer;
  32.   function ntohl (netlong : u_long) : u_long;
  33.   function ntohs (netshort : u_short) : u_short;
  34.   function recv (s : SOCKET; buf : PChar; len, flags : integer) : integer;
  35.   function recvfrom (s : SOCKET; buf : PChar; len, flags : integer; from : sockaddr; fromlen : integer) : integer;
  36.   function select (nfds : integer; readfds, writefds, exceptfds : fd_set; timeout : timeval) : longint;
  37.   function send (s : SOCKET; buf : PChar; len, flags : integer) : integer;
  38.   function sendto (s : SOCKET; buf : PChar; len, flags : integer; addrto : sockaddr; tolen : integer) : integer;
  39.   function setsockopt (s : SOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  40.   function shutdown (s : SOCKET; how : integer) : integer;
  41.   function _socket (af, struct, protocol : integer) : SOCKET;
  42.   function gethostbyaddr (addr : PChar; len, struct : integer) : PHostEnt; { hostent }
  43.   function gethostbyname (name : PChar) : PHostEnt; { hostent }
  44.   function getservbyport (port : integer; proto : PChar) : PServEnt; { servent }
  45.   function getservbyname (name, proto : PChar) : PServEnt; { servent }
  46.   function getprotobynumber (proto : integer) : PProtoEnt; { protoent }
  47.   function getprotobyname (name : PChar) : PProtoEnt; { protoent }
  48.   function WSAStartup (wVersionRequired : word; lpWSData : LPWSADATA) : integer;
  49.   function WSACleanup : integer;
  50.   procedure WSASetLastError (iError : integer);
  51.   function WSAGetLastError : integer;
  52.   function WSAIsBlocking : BOOL;
  53.   function WSAUnhookBlockingHook : integer;
  54.   function WSASetBlockingHook (lpBlockFunc : TFarProc) : TFarProc;
  55.   function WSACancelBlockingCall : integer;
  56.   function WSAAsyncGetServByName (HWindow : HWND; wMsg : u_int; name, proto, buf : PChar; buflen : integer) : THandle;
  57.   function WSAAsyncGetServByPort ( HWindow : HWND; wMsg, port : u_int; proto, buf : PChar; buflen : integer) : THandle;
  58.   function WSAAsyncGetProtoByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  59.   function WSAAsyncGetProtoByNumber (HWindow : HWND; wMsg : u_int; number : integer;
  60.                                       buf : PChar; buflen : integer) : THandle;
  61.   function WSAAsyncGetHostByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  62.   function WSAAsyncGetHostByAddr (HWindow : HWND; wMsg : u_int; addr : PChar; len, struct : integer;
  63.                                   buf : PChar; buflen : integer) : THandle;
  64.   function WSACancelAsyncRequest (hAsyncTaskHandle : THandle) : integer;
  65.   function WSAAsyncSelect (s : SOCKET; HWindow : HWND; wMsg : u_int; lEvent : longint) : integer;
  66.  
  67.  
  68. function WSAMakeSyncReply (Buflen, Error : Word) : LongInt;
  69. function WSAMakeSelectReply (Event, Error : Word) : LongInt;
  70. function WSAGetAsyncBuflen (Param : LongInt) : Word;
  71. function WSAGetAsyncError (Param : LongInt) : Word;
  72. function WSAGetSelectEvent (Param : LongInt) : Word;
  73. function WSAGetSelectError (Param : LongInt) : Word;
  74.  
  75. implementation
  76.  
  77. var
  78.    fdSet : fd_set;
  79.  
  80. function FIONBIO (x, y : integer; t : u_long) : u_long;
  81. begin
  82.      FIONBIO := (IOC_IN OR ((IOCPARM_MASK shl 16) OR (x SHL 8) OR (Y)));
  83. end;
  84.  
  85. function WSAMakeSyncReply;
  86. begin
  87.      WSAMakeSyncReply := MakeLong (Buflen, Error);
  88. end;
  89.  
  90. function WSAMakeSelectReply;
  91. begin
  92.      WSAMakeSelectReply := MakeLong (Event, Error);
  93. end;
  94.  
  95. function WSAGetAsyncBuflen;
  96. begin
  97.      WSAGetAsyncBuflen := LOWORD(Param);
  98. end;
  99.  
  100. function WSAGetAsyncError;
  101. begin
  102.      WSAGetAsyncError := HIWORD(Param);
  103. end;
  104.  
  105. function WSAGetSelectEvent;
  106. begin
  107.      WSAGetSelectEvent := LOWORD(Param);
  108. end;
  109.  
  110. function WSAGetSelectError;
  111. begin
  112.      WSAGetSelectError := HIWORD(Param);
  113. end;
  114.  
  115. function accept;            external    'WINSOCK' index 1;
  116. function bind;              external    'WINSOCK' index 2;
  117. function closesocket;       external    'WINSOCK' index 3;
  118. function connect;           external    'WINSOCK' index 4;
  119. function ioctlsocket;       external    'WINSOCK' index 12;
  120. function getpeername;       external    'WINSOCK' index 5;
  121. function getsockname;       external    'WINSOCK' index 6;
  122. function getsockopt;        external    'WINSOCK' index 7;
  123. function htonl;             external    'WINSOCK' index 8;
  124. function htons;             external    'WINSOCK' index 9;
  125. function inet_addr;         external    'WINSOCK' index 10;
  126. function inet_ntoa;         external    'WINSOCK' index 11;
  127. function listen;            external    'WINSOCK' index 13;
  128. function ntohl;             external    'WINSOCK' index 14;
  129. function ntohs;             external    'WINSOCK' index 15;
  130. function recv;              external    'WINSOCK' index 16;
  131. function recvfrom;          external    'WINSOCK' index 17;
  132. function select;            external    'WINSOCK' index 18;
  133. function send;              external    'WINSOCK' index 19;
  134. function sendto;            external    'WINSOCK' index 20;
  135. function setsockopt;        external    'WINSOCK' index 21;
  136. function shutdown;          external    'WINSOCK' index 22;
  137. function _socket;            external    'WINSOCK' index 23;
  138.  
  139. function gethostbyaddr;     external    'WINSOCK' index 51;
  140. function gethostbyname;     external    'WINSOCK' index 52;
  141. function getprotobyname;    external    'WINSOCK' index 53;
  142. function getprotobynumber;  external    'WINSOCK' index 54;
  143. function getservbyname;     external    'WINSOCK' index 55;
  144. function getservbyport;     external    'WINSOCK' index 56;
  145.  
  146. function WSAAsyncSelect;    external    'WINSOCK' index 101;
  147. function WSAAsyncGetHostByAddr; external 'WINSOCK' index 102;
  148. function WSAAsyncGetHostByName; external 'WINSOCK' index 103;
  149. function WSAAsyncGetProtoByNumber; external 'WINSOCK' index 104;
  150. function WSAAsyncGetprotoByName; external 'WINSOCK' index 105;
  151. function WSAAsyncGetServByPort; external 'WINSOCK' index 106;
  152. function WSAAsyncGetServByName; external 'WINSOCK' index 107;
  153. function WSACancelAsyncRequest; external 'WINSOCK' index 108;
  154. function WSASetBlockingHook; external    'WINSOCK' index 109;
  155. function WSAUnhookBlockingHook; external 'WINSOCK' index 110;
  156. function WSAGetLastError;    external    'WINSOCK' index 111;
  157. procedure WSASetLastError;   external    'WINSOCK' index 112;
  158. function WSACancelBlockingCall; external 'WINSOCK' index 113;
  159. function WSAIsBlocking;     external     'WINSOCK' index 114;
  160. function WSAStartup;        external     'WINSOCK' index 115;
  161. function WSACleanup;        external     'WINSOCK' index 116;
  162.  
  163. end.