home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / WINSOCK / PASTEL10 / WINSOCK.PAS < prev   
Pascal/Delphi Source File  |  1994-11-15  |  8KB  |  174 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. {
  12.   Modified by Mike Caughran Cedar Island Software
  13.   Added gethostname.
  14.   changed _socket() to socket().
  15.   changed references to SOCKET to tSOCKET.
  16.   changed accept parms from tSocket,SockAddr,Integer to tSocket,PSockAddr,PInteger
  17. }
  18.  
  19. interface
  20.  
  21. uses WIN31, WinTypes, WinProcs;
  22.  
  23. {$I winsock.inc }
  24.  
  25. { Library Functions }
  26.  
  27.   function accept (s : tSOCKET; addr : PSockaddr; addrlen : PInteger) : tSOCKET;
  28.   function bind (s : tSOCKET; addr : sockaddr; namelen : integer) : integer;
  29.   function closesocket (s : tSOCKET) : integer;
  30.   function connect (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  31.   function ioctlsocket (s : tSOCKET; cmd : longint; argp : u_long) : integer;
  32.   function getpeername (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  33.   function getsockname (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  34.   function getsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  35.   function htonl (hostlong : u_long) : u_long;
  36.   function htons (hostshort : u_short) : u_short;
  37.   function inet_addr (cp : PChar) : PIn_Addr;  { in_addr }
  38.   function inet_ntoa (inaddr : in_addr) : PChar;
  39.   function listen (s : tSOCKET; backlog : integer) : integer;
  40.   function ntohl (netlong : u_long) : u_long;
  41.   function ntohs (netshort : u_short) : u_short;
  42.   function recv (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  43.   function recvfrom (s : tSOCKET; buf : PChar; len, flags : integer; from : sockaddr; fromlen : integer) : integer;
  44.   function select (nfds : integer; readfds, writefds, exceptfds : fd_set; timeout : timeval) : longint;
  45.   function send (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  46.   function sendto (s : tSOCKET; buf : PChar; len, flags : integer; addrto : sockaddr; tolen : integer) : integer;
  47.   function setsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  48.   function shutdown (s : tSOCKET; how : integer) : integer;
  49.   function socket (af, struct, protocol : integer) : tSOCKET;
  50.   function gethostbyaddr (addr : PChar; len, struct : integer) : PHostEnt; { hostent }
  51.   function gethostbyname (name : PChar) : PHostEnt; { hostent }
  52.   function gethostname (name : PChar; len : integer) : integer;
  53.   function getservbyport (port : integer; proto : PChar) : PServEnt; { servent }
  54.   function getservbyname (name, proto : PChar) : PServEnt; { servent }
  55.   function getprotobynumber (proto : integer) : PProtoEnt; { protoent }
  56.   function getprotobyname (name : PChar) : PProtoEnt; { protoent }
  57.   function WSAStartup (wVersionRequired : word; lpWSData : LPWSADATA) : integer;
  58.   function WSACleanup : integer;
  59.   procedure WSASetLastError (iError : integer);
  60.   function WSAGetLastError : integer;
  61.   function WSAIsBlocking : BOOL;
  62.   function WSAUnhookBlockingHook : integer;
  63.   function WSASetBlockingHook (lpBlockFunc : TFarProc) : TFarProc;
  64.   function WSACancelBlockingCall : integer;
  65.   function WSAAsyncGetServByName (HWindow : HWND; wMsg : u_int; name, proto, buf : PChar; buflen : integer) : THandle;
  66.   function WSAAsyncGetServByPort ( HWindow : HWND; wMsg, port : u_int; proto, buf : PChar; buflen : integer) : THandle;
  67.   function WSAAsyncGetProtoByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  68.   function WSAAsyncGetProtoByNumber (HWindow : HWND; wMsg : u_int; number : integer;
  69.                                       buf : PChar; buflen : integer) : THandle;
  70.   function WSAAsyncGetHostByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  71.   function WSAAsyncGetHostByAddr (HWindow : HWND; wMsg : u_int; addr : PChar; len, struct : integer;
  72.                                   buf : PChar; buflen : integer) : THandle;
  73.   function WSACancelAsyncRequest (hAsyncTaskHandle : THandle) : integer;
  74.   function WSAAsyncSelect (s : tSOCKET; HWindow : HWND; wMsg : u_int; lEvent : longint) : integer;
  75.  
  76.  
  77. function WSAMakeSyncReply (Buflen, Error : Word) : LongInt;
  78. function WSAMakeSelectReply (Event, Error : Word) : LongInt;
  79. function WSAGetAsyncBuflen (Param : LongInt) : Word;
  80. function WSAGetAsyncError (Param : LongInt) : Word;
  81. function WSAGetSelectEvent (Param : LongInt) : Word;
  82. function WSAGetSelectError (Param : LongInt) : Word;
  83.  
  84. implementation
  85.  
  86. var
  87.    fdSet : fd_set;
  88.  
  89. function FIONBIO (x, y : integer; t : u_long) : u_long;
  90. begin
  91.      FIONBIO := (IOC_IN OR ((IOCPARM_MASK shl 16) OR (x SHL 8) OR (Y)));
  92. end;
  93.  
  94. function WSAMakeSyncReply;
  95. begin
  96.      WSAMakeSyncReply := MakeLong (Buflen, Error);
  97. end;
  98.  
  99. function WSAMakeSelectReply;
  100. begin
  101.      WSAMakeSelectReply := MakeLong (Event, Error);
  102. end;
  103.  
  104. function WSAGetAsyncBuflen;
  105. begin
  106.      WSAGetAsyncBuflen := LOWORD(Param);
  107. end;
  108.  
  109. function WSAGetAsyncError;
  110. begin
  111.      WSAGetAsyncError := HIWORD(Param);
  112. end;
  113.  
  114. function WSAGetSelectEvent;
  115. begin
  116.      WSAGetSelectEvent := LOWORD(Param);
  117. end;
  118.  
  119. function WSAGetSelectError;
  120. begin
  121.      WSAGetSelectError := HIWORD(Param);
  122. end;
  123.  
  124. function accept;            external    'WINSOCK' index 1;
  125. function bind;              external    'WINSOCK' index 2;
  126. function closesocket;       external    'WINSOCK' index 3;
  127. function connect;           external    'WINSOCK' index 4;
  128. function getpeername;       external    'WINSOCK' index 5;
  129. function getsockname;       external    'WINSOCK' index 6;
  130. function getsockopt;        external    'WINSOCK' index 7;
  131. function htonl;             external    'WINSOCK' index 8;
  132. function htons;             external    'WINSOCK' index 9;
  133. function inet_addr;         external    'WINSOCK' index 10;
  134. function inet_ntoa;         external    'WINSOCK' index 11;
  135. function ioctlsocket;       external    'WINSOCK' index 12;
  136. function listen;            external    'WINSOCK' index 13;
  137. function ntohl;             external    'WINSOCK' index 14;
  138. function ntohs;             external    'WINSOCK' index 15;
  139. function recv;              external    'WINSOCK' index 16;
  140. function recvfrom;          external    'WINSOCK' index 17;
  141. function select;            external    'WINSOCK' index 18;
  142. function send;              external    'WINSOCK' index 19;
  143. function sendto;            external    'WINSOCK' index 20;
  144. function setsockopt;        external    'WINSOCK' index 21;
  145. function shutdown;          external    'WINSOCK' index 22;
  146. function socket;            external    'WINSOCK' index 23;
  147.  
  148. function gethostbyaddr;     external    'WINSOCK' index 51;
  149. function gethostbyname;     external    'WINSOCK' index 52;
  150. function getprotobyname;    external    'WINSOCK' index 53;
  151. function getprotobynumber;  external    'WINSOCK' index 54;
  152. function getservbyname;     external    'WINSOCK' index 55;
  153. function getservbyport;     external    'WINSOCK' index 56;
  154. function gethostname;       external    'WINSOCK' index 57;
  155.  
  156. function WSAAsyncSelect;    external    'WINSOCK' index 101;
  157. function WSAAsyncGetHostByAddr; external 'WINSOCK' index 102;
  158. function WSAAsyncGetHostByName; external 'WINSOCK' index 103;
  159. function WSAAsyncGetProtoByNumber; external 'WINSOCK' index 104;
  160. function WSAAsyncGetprotoByName; external 'WINSOCK' index 105;
  161. function WSAAsyncGetServByPort; external 'WINSOCK' index 106;
  162. function WSAAsyncGetServByName; external 'WINSOCK' index 107;
  163. function WSACancelAsyncRequest; external 'WINSOCK' index 108;
  164. function WSASetBlockingHook; external    'WINSOCK' index 109;
  165. function WSAUnhookBlockingHook; external 'WINSOCK' index 110;
  166. function WSAGetLastError;    external    'WINSOCK' index 111;
  167. procedure WSASetLastError;   external    'WINSOCK' index 112;
  168. function WSACancelBlockingCall; external 'WINSOCK' index 113;
  169. function WSAIsBlocking;     external     'WINSOCK' index 114;
  170. function WSAStartup;        external     'WINSOCK' index 115;
  171. function WSACleanup;        external     'WINSOCK' index 116;
  172.  
  173. end.
  174.