Winsock Library for BPW 
Author Message
 Winsock Library for BPW

I am looking for some information how to talk to Winsock, in particuliar
in Windows 95.

Any information, resource or code would be very much appreciated.

Thanks.



Wed, 18 Jun 1902 08:00:00 GMT  
 Winsock Library for BPW

I'm using it now. Hope it will work for you.

[ winsock.pas 11K ]
unit WINSOCK;

{ Winsock.h file for Borland Pascal
  Conversion by Marc B. Manza
             Center for Applied Large-Scale Computing
  Requires Winsock.pas and Winsock.inc

  Send any comments/change requests/etc. to:

{
  Modified by Mike Caughran Cedar Island Software
  Added gethostname.
  changed _socket() to socket().
  changed references to SOCKET to tSOCKET.
  changed accept parms from tSocket,SockAddr,Integer
                         to tSocket,PSockAddr,PInteger

Quote:
}

interface

uses WIN31, WinTypes, WinProcs;

{$I winsock.inc }

{ Library Functions }

  function accept (s : tSOCKET; addr : PSockaddr; addrlen : PInteger) : tSOCKET;
  function bind (s : tSOCKET; addr : sockaddr; namelen : integer) : integer;
  function closesocket (s : tSOCKET) : integer;
  function connect (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  function ioctlsocket (s : tSOCKET; cmd : longint; argp : u_long) : integer;
  function getpeername (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  function getsockname (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  function getsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  function htonl (hostlong : u_long) : u_long;
  function htons (hostshort : u_short) : u_short;
  function inet_addr (cp : PChar) : PIn_Addr;  { in_addr }
  function inet_ntoa (inaddr : in_addr) : PChar;
  function listen (s : tSOCKET; backlog : integer) : integer;
  function ntohl (netlong : u_long) : u_long;
  function ntohs (netshort : u_short) : u_short;
  function recv (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  function recvfrom (s : tSOCKET; buf : PChar; len, flags : integer; from : sockaddr; fromlen : integer) : integer;
  function select (nfds : integer; readfds, writefds, exceptfds : fd_set; timeout : timeval) : longint;
  function send (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  function sendto (s : tSOCKET; buf : PChar; len, flags : integer; addrto : sockaddr; tolen : integer) : integer;
  function setsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  function shutdown (s : tSOCKET; how : integer) : integer;
  function socket (af, struct, protocol : integer) : tSOCKET;
  function gethostbyaddr (addr : PChar; len, struct : integer) : PHostEnt; { hostent }
  function gethostbyname (name : PChar) : PHostEnt; { hostent }
  function gethostname (name : PChar; len : integer) : integer;
  function getservbyport (port : integer; proto : PChar) : PServEnt; { servent }
  function getservbyname (name, proto : PChar) : PServEnt; { servent }
  function getprotobynumber (proto : integer) : PProtoEnt; { protoent }
  function getprotobyname (name : PChar) : PProtoEnt; { protoent }
  function WSAStartup (wVersionRequired : word; lpWSData : LPWSADATA) : integer;
  function WSACleanup : integer;
  procedure WSASetLastError (iError : integer);
  function WSAGetLastError : integer;
  function WSAIsBlocking : BOOL;
  function WSAUnhookBlockingHook : integer;
  function WSASetBlockingHook (lpBlockFunc : TFarProc) : TFarProc;
  function WSACancelBlockingCall : integer;
  function WSAAsyncGetServByName (HWindow : HWND; wMsg : u_int; name, proto, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetServByPort ( HWindow : HWND; wMsg, port : u_int; proto, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetProtoByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetProtoByNumber (HWindow : HWND; wMsg : u_int; number : integer;
                                      buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetHostByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetHostByAddr (HWindow : HWND; wMsg : u_int; addr : PChar; len, struct : integer;
                                  buf : PChar; buflen : integer) : THandle;
  function WSACancelAsyncRequest (hAsyncTaskHandle : THandle) : integer;
  function WSAAsyncSelect (s : tSOCKET; HWindow : HWND; wMsg : u_int; lEvent : longint) : integer;

function WSAMakeSyncReply (Buflen, Error : Word) : LongInt;
function WSAMakeSelectReply (Event, Error : Word) : LongInt;
function WSAGetAsyncBuflen (Param : LongInt) : Word;
function WSAGetAsyncError (Param : LongInt) : Word;
function WSAGetSelectEvent (Param : LongInt) : Word;
function WSAGetSelectError (Param : LongInt) : Word;

implementation

var
   fdSet : fd_set;

function FIONBIO (x, y : integer; t : u_long) : u_long;
begin
     FIONBIO := (IOC_IN OR ((IOCPARM_MASK shl 16) OR (x SHL 8) OR (Y)));
end;

function WSAMakeSyncReply;
begin
     WSAMakeSyncReply := MakeLong (Buflen, Error);
end;

function WSAMakeSelectReply;
begin
     WSAMakeSelectReply := MakeLong (Event, Error);
end;

function WSAGetAsyncBuflen;
begin
     WSAGetAsyncBuflen := LOWORD(Param);
end;

function WSAGetAsyncError;
begin
     WSAGetAsyncError := HIWORD(Param);
end;

function WSAGetSelectEvent;
begin
     WSAGetSelectEvent := LOWORD(Param);
end;

function WSAGetSelectError;
begin
     WSAGetSelectError := HIWORD(Param);
end;

function accept;            external    'WINSOCK' index 1;
function bind;              external    'WINSOCK' index 2;
function closesocket;       external    'WINSOCK' index 3;
function connect;           external    'WINSOCK' index 4;
function getpeername;       external    'WINSOCK' index 5;
function getsockname;       external    'WINSOCK' index 6;
function getsockopt;        external    'WINSOCK' index 7;
function htonl;             external    'WINSOCK' index 8;
function htons;             external    'WINSOCK' index 9;
function inet_addr;         external    'WINSOCK' index 10;
function inet_ntoa;         external    'WINSOCK' index 11;
function ioctlsocket;       external    'WINSOCK' index 12;
function listen;            external    'WINSOCK' index 13;
function ntohl;             external    'WINSOCK' index 14;
function ntohs;             external    'WINSOCK' index 15;
function recv;              external    'WINSOCK' index 16;
function recvfrom;          external    'WINSOCK' index 17;
function select;            external    'WINSOCK' index 18;
function send;              external    'WINSOCK' index 19;
function sendto;            external    'WINSOCK' index 20;
function setsockopt;        external    'WINSOCK' index 21;
function shutdown;          external    'WINSOCK' index 22;
function socket;            external    'WINSOCK' index 23;

function gethostbyaddr;     external    'WINSOCK' index 51;
function gethostbyname;     external    'WINSOCK' index 52;
function getprotobyname;    external    'WINSOCK' index 53;
function getprotobynumber;  external    'WINSOCK' index 54;
function getservbyname;     external    'WINSOCK' index 55;
function getservbyport;     external    'WINSOCK' index 56;
function gethostname;       external    'WINSOCK' index 57;

function WSAAsyncSelect;    external    'WINSOCK' index 101;
function WSAAsyncGetHostByAddr; external 'WINSOCK' index 102;
function WSAAsyncGetHostByName; external 'WINSOCK' index 103;
function WSAAsyncGetProtoByNumber; external 'WINSOCK' index 104;
function WSAAsyncGetprotoByName; external 'WINSOCK' index 105;
function WSAAsyncGetServByPort; external 'WINSOCK' index 106;
function WSAAsyncGetServByName; external 'WINSOCK' index 107;
function WSACancelAsyncRequest; external 'WINSOCK' index 108;
function WSASetBlockingHook; external    'WINSOCK' index 109;
function WSAUnhookBlockingHook; external 'WINSOCK' index 110;
function WSAGetLastError;    external    'WINSOCK' index 111;
procedure WSASetLastError;   external    'WINSOCK' index 112;
function WSACancelBlockingCall; external 'WINSOCK' index 113;
function WSAIsBlocking;     external     'WINSOCK' index 114;
function WSAStartup;        external     'WINSOCK' index 115;
function WSACleanup;        external     'WINSOCK' index 116;

end.

[ winsock.inc 15K ]
{ Winsock.h file for Borland Pascal
  Conversion by Marc B. Manza
             Center for Applied Large-Scale Computing
  Requires Winsock.pas and Winsock.inc
  Send any comments/change requests/etc. to:

Quote:
}

{
  Modified by Mike Caughran Cedar Island Software Nov 1994
  Changed references to SOCKET to tSOCKET
  added INADDR_ANY
  added PInteger

Quote:
}

type
    u_char = char;
    u_short = word; { byte ?? }
    u_int = word;
    u_long = longint;

    tSOCKET = u_int;

const
     FD_SETSIZE     =   64;

type
    fd_set = record
                   fd_count : u_short;
                   fd_array : array[0..FD_SETSIZE-1] of tSOCKET;
    end;

    timeval = record
                    tv_sec, tv_usec : longint;
    end;

const
     IOCPARM_MASK   =   $007f;
     IOC_VOID       =   $20000000;
     IOC_OUT        =   $40000000;
     IOC_IN         =   $80000000;
     IOC_INOUT      =   (IOC_IN OR IOC_OUT);

type
    PPchar = ^PChar;

    hostent = record
                    h_name : PChar;
                    h_aliases : PPChar;
                    h_addrtype : integer;
                    h_length : integer;
                    h_addr_list : PPChar;
                    h_addr : PChar;    
    end;

    netent = record
                   n_name : PChar;
                   n_aliases : ^PChar;
                   n_addrtype : integer;
                   n_net : u_long;
    end;

    servent = record
                    s_name : PChar;
                    s_aliases : ^PChar;
                    s_port : integer;
                    s_proto : PChar;
    end;

    protoent = record
                     p_name : PChar;
                     p_aliases : ^Pchar;
                     p_proto : integer;
    end;

const
     IPPROTO_IP     =   0;
     IPPROTO_ICMP   =   1;
     IPPROTO_GGP    =   2;
     IPPROTO_TCP    =   6;
     IPPROTO_PUP    =   12;
     IPPROTO_UDP    =   17;
     IPPROTO_IDP    =   22;
     IPPROTO_ND     =   77;

     IPPROTO_RAW    =   255;
     IPPROTO_MAX    =   256;

     IPPORT_ECHO    =   7;
     IPPORT_DISCARD =   9;
     IPPORT_SYSTAT  =   11;
     IPPORT_DAYTIME =   13;
     IPPORT_NETSTAT =   15;
     IPPORT_FTP     =   21;
     IPPORT_TELNET  =   23;
     IPPORT_SMTP    =   25;
     IPPORT_TIMESERVER  =  37;
     IPPORT_NAMESERVER  =  42;
     IPPORT_WHOIS       =  43;
     IPPORT_MTP         =  57;

     IPPORT_TFTP        =  69;
     IPPORT_RJE         =  77;
     IPPORT_FINGER      =  79;
     IPPORT_TTYLINK     =  87;
     IPPORT_SUPDUP      =  95;

     IPPORT_EXECSERVER  =  512;
     IPPORT_LOGINSERVER =  513;
     IPPORT_CMDSERVER   =  514;
     IPPORT_EFSSERVER   =  520;

     IPPORT_BIFFUDP     =  512;
     IPPORT_WHOSERVER   =  513;
     IPPORT_ROUTESERVER =  520;

     IPPORT_RESERVED    =  1024;

     IMPLINK_IP         =  155;
     IMPLINK_LOWEXPER   =  156;
     IMPLINK_HIGHEXPER  =  158;

Type
     SunB = record
                  s_b1, s_b2, s_b3, s_b4 : u_char;

     end;

     SunW = record
                  s_w1, s_w2 : u_short;
     end;

     in_addr = record
                 case integer of
                          0 : (S_un_b : SunB);
                          1 : (S_un_w : SunW);
                          2 : (S_addr : u_long);
     end;

var
   S_un : in_addr;

type
    sockaddr_in = record
                        sin_family : integer;
                        sin_port : u_short;
                        sin_addr : in_addr;
                        sin_zero : array[0..7] of char;
    end;

const
     WSADESCRIPTION_LEN     =   256;
     WSASYS_STATUS_LEN      =   128;

type
    LPWSADATA = ^WSAData;
    WSAData = record
                    wVersion : word;
                    wHighVersion : word;
                    szDescription : array[0..WSADESCRIPTION_LEN] of char;
                    szSystemStatus : array[0..WSASYS_STATUS_LEN] of char;
                    iMaxSockets : integer;
                    iMaxUdpDg : integer;
                    lpVendorInfo : PChar;
    end;

const
     IP_OPTIONS     =   1;
     INADDR_ANY     =   0;    {msc}

     INVALID_SOCKET =   NOT(0);
     SOCKET_ERROR   =   -1;

     SOCK_STREAM    =   1;
     SOCK_DGRAM     =   2;
     SOCK_RAW       =   3;
     SOCK_RDM       =   4;
     SOCK_SEQPACKET =   5;

     SO_DEBUG       =   $0001;
     SO_ACCEPTCONN  =   $0002;
     SO_REUSEADDR   =   $0004;
     SO_KEEPALIVE   =   $0008;
     SO_DONTROUTE   =   $0010;
     SO_BROADCAST   =   $0020;
     SO_USELOOPBACK =   $0040;
     SO_LINGER      =   $0080;
     SO_OOBINLINE   =   $0100;

     SO_DONTLINGER  =   $ff7f;

     SO_SNDBUF      =   $1001;
     SO_RCVBUF      =   $1002;
     SO_SNDLOWAT    =   $1003;
     SO_RCVLOWAT    =   $1004;
     SO_SNDTIMEO    =   $1005;
     SO_RCVTIMEO    =   $1006;
     SO_ERROR       =   $1007;
     SO_TYPE        =   $1008;

     AF_UNSPEC      =   0;
     AF_UNIX        =   1;
     AF_INET        =   2;
     AF_IMPLINK     =   3;
     AF_PUP         =   4;
     AF_CHAOS       =   5;
     AF_NS          =   6;
     AF_NBS         =   7;
     AF_ECMA        =   8;
     AF_DATAKIT     =   9;
     AF_CCITT       =   10;
     AF_SNA         =   11;
     AF_DECnet      =   12;
     AF_DLI         =   13;
     AF_LAT         =   14;
     AF_HYLINK      =   15;
     AF_APPLETALK   =   16;

     AF_MAX         =   17;

type
    sockaddr = record
                     sa_family : u_short;
                     sa_data : array[0..13] of char; { should be 0..13 ?}
    end;

    sockproto = record
                      sp_family : u_short;
                      sp_protocol : u_short;
    end;

const
     PF_UNSPEC      =   AF_UNSPEC;
     PF_UNIX        =   AF_UNIX;
     PF_INET        =   AF_INET;
     PF_IMPLINK     =   AF_IMPLINK;
     PF_PUP         =   AF_PUP;
     PF_CHAOS       =   AF_CHAOS;
     PF_NS          =   AF_NS;
     PF_NBS         =   AF_NBS;
     PF_ECMA        =   AF_ECMA;
     PF_DATAKIT     =   AF_DATAKIT;
     PF_CCITT       =   AF_CCITT;
     PF_SNA         =   AF_SNA;
     PF_DECnet      =   AF_DECnet;
     PF_DLI         =   AF_DLI;
     PF_LAT         =   AF_LAT;
     PF_HYLINK      =   AF_HYLINK;
     PF_APPLETALK   =   AF_APPLETALK;

     PF_MAX         =   AF_MAX;        

type
    linger = record
                   l_onoff : u_short;
                   l_linger : u_short;
    end;

const
     SOL_SOCKET     =   $ffff;

     SOMAXCONN      =   5;

     MSG_OOB        =   $1;
     MSG_PEEK       =   $2;
     MSG_DONTROUTE  =   $4;

     MSG_MAXIOVLEN  =   16;

     MAXGETHOSTSTRUCT   =  1024;

     FD_READ            =  $01;
     FD_WRITE           =  $02;
     FD_OOB             =  $04;
     FD_ACCEPT          =  $08;
     FD_CONNECT         =  $10;
     FD_CLOSE           =  $20;

     WSABASEERR         =  10000;

     WSAEINTR           =  (WSABASEERR + 4);
     WSAEBADF           =  (WSABASEERR + 9);
     WSAEFAULT          =  (WSABASEERR + 14);
     WSAEINVAL          =  (WSABASEERR + 22);
     WSAEMFILE          =  (WSABASEERR + 24);

     WSAEWOULDBLOCK     =  (WSABASEERR + 35);
     WSAEINPROGRESS     =  (WSABASEERR + 36);
     WSAEALREADY        =  (WSABASEERR + 37);
     WSAENOTSOCK        =  (WSABASEERR + 38);
     WSAEDESTADDRREQ    =  (WSABASEERR + 39);
     WSAEMSGSIZE        =  (WSABASEERR + 40);
     WSAEPROTOTYPE      =  (WSABASEERR + 41);
     WSAENOPROTOOPT     =  (WSABASEERR + 42);
     WSAEPROTONOSUPPORT =  (WSABASEERR + 43);
     WSAESOCKTNOSUPPORT  =  (WSABASEERR + 44);
     WSAEOPNOTSUPP      =  (WSABASEERR + 45);
     WSAEPFNOSUPPORT    =  (WSABASEERR + 46);
     WSAEAFNOSUPPORT    =  (WSABASEERR + 47);
     WSAEADDRINUSE      =  (WSABASEERR + 48);
     WSAEADDRNOTAVAIL   =  (WSABASEERR + 49);
     WSAENETDOWN        =  (WSABASEERR + 50);
     WSAENETUNREACH     =  (WSABASEERR + 51);
     WSAENETRESET       =  (WSABASEERR + 52);
     WSAECONNABORTED    =  (WSABASEERR + 53);
     WSAECONNRESET      =  (WSABASEERR + 54);
     WSAENOBUFS         =  (WSABASEERR + 55);
     WSAEISCONN         =  (WSABASEERR + 56);
     WSAENOTCONN        =  (WSABASEERR + 57);
     WSAESHUTDOWN       =  (WSABASEERR + 58);
     WSAETOOMANYREFS    =  (WSABASEERR + 59);
     WSAETIMEDOUT       =  (WSABASEERR + 60);
     WSAECONNREFUSED    =  (WSABASEERR + 61);
     WSAELOOP           =  (WSABASEERR + 62);
     WSAENAMETOOLONG    =  (WSABASEERR + 63);
     WSAEHOSTDOWN       =  (WSABASEERR + 64);
     WSAEHOSTUNREACH    =  (WSABASEERR + 65);
     WSAENOTEMPTY       =  (WSABASEERR + 66);
     WSAEPROCLIM        =  (WSABASEERR + 67);
     WSAEUSERS          =  (WSABASEERR + 68);
     WSAEDQUOT          =  (WSABASEERR + 69);
     WSAESTALE          =  (WSABASEERR + 70);
     WSAEREMOTE         =  (WSABASEERR + 71);

     WSASYSNOTREADY     =  (WSABASEERR + 91);
     WSAVERNOTSUPPORTED =  (WSABASEERR + 92);
     WSANOTINITIALISED  =  (WSABASEERR + 93);

     WSAHOST_NOT_FOUND  =  (WSABASEERR + 1001);
     HOST_NOT_FOUND     =  WSAHOST_NOT_FOUND;

     WSATRY_AGAIN       =  (WSABASEERR + 1002);
     TRY_AGAIN          =  WSATRY_AGAIN;

     WSANO_RECOVERY     =  (WSABASEERR + 1003);
     NO_RECOVERY        =  WSANO_RECOVERY;

     WSANO_DATA         =  (WSABASEERR + 1004);
     NO_DATA            =  WSANO_DATA;

     WSANO_ADDRESS      =  WSANO_DATA;
     NO_ADDRESS         =  WSANO_ADDRESS;

     EWOULDBLOCK
...

read more »



Wed, 18 Jun 1902 08:00:00 GMT  
 Winsock Library for BPW

Quote:

>I am looking for some information how to talk to Winsock, in
particuliar
>in Windows 95.
>> Look for PASOCK10.ZIP and WINSOCK.HLP files. If you have

difficulties let me know and I will mail them to you.
Quote:
>> Martin
>Any information, resource or code would be very much appreciated.

>Thanks.



Wed, 18 Jun 1902 08:00:00 GMT  
 Winsock Library for BPW

Quote:

> I am looking for some information how to talk to Winsock, in particuliar
> in Windows 95.

> Any information, resource or code would be very much appreciated.

  A while ago, i was looking for the same thing, and i found a
file PASOCK10.ZIP from Mike Caughran containing code to access
WinSock from Pascal.  Following is the Readme that came with it.

  If you can't get the file from the site, write me and i will
send mine to you.

  Have Fun

Stphane Aubry
DND Network Manager

------------- README.TXT ------------------
Tested with Trumpet, Novell, WFW, NT  tcp stacks.
Please keep this zip file intact.

Mike Caughran
Cedar Island Software
9018 Division St
Juneau Alaska
99081
907-789-9030

readme.txt   -- this file
finger.pas   --  sample winsock client code showing "hello from finger world"
fingerd.pas  --  sample winsock server code showing "hello from fingerd world"
error.inc    -- finger and fingerd error messages
winsock.inc  --  header file for winsock.pas
winsock.pas  --  interface unit for winsock.dll
crtclass.pas -- sample program which shows how to hook wincrt to
                add a menubar and messageproc.
errono.rc    -- a resource file containing a string table which could
                be used with a LoadString command  
                (not used with finger or fingerd)

References:
sunsite.unc.edu    (winsock.hlp and sample code there)
Doctor Dobbs       (feb 1993 issue)
Marc Manza



Wed, 18 Jun 1902 08:00:00 GMT  
 Winsock Library for BPW


==>I am looking for some information how to talk to Winsock, in
particuliar
==>in Windows 95.

==>Any information, resource or code would be very much appreciated.

==>Thanks.

------------------------------------------------------------------------------------------------------
Here is what I have. Don't ask me any questions, as I have never used
this:

------------------------------------------------------------------------------------------------------
unit WINSOCK;

{ Winsock.h file for Borland Pascal
  Conversion by Marc B. Manza
             Center for Applied Large-Scale Computing
  Requires Winsock.pas and Winsock.inc
I DON'T HAVE THE .PAS and .INC FILE!!!
  Send any comments/change requests/etc. to:

interface

uses WIN31, WinTypes, WinProcs;

{$I winsock.inc }

{ Library Functions }

  function accept (s : SOCKET; addr : sockaddr; addrlen : integer) :
SOCKET;
  function bind (s : SOCKET; addr : sockaddr; namelen : integer) :
integer;
  function closesocket (s : SOCKET) : integer;
  function connect (s : SOCKET; name : sockaddr; namelen : integer) :
integer;
  function ioctlsocket (s : SOCKET; cmd : longint; argp : u_long) :
integer;
  function getpeername (s : SOCKET; name : sockaddr; namelen :
integer) : integer;
  function getsockname (s : SOCKET; name : sockaddr; namelen :
integer) : integer;
  function getsockopt (s : SOCKET; level, optname : integer; optval :
PChar; optlen : integer) : integer;
  function htonl (hostlong : u_long) : u_long;
  function htons (hostshort : u_short) : u_short;
  function inet_addr (cp : PChar) : PIn_Addr;  { in_addr }
  function inet_ntoa (inaddr : in_addr) : PChar;
  function listen (s : SOCKET; backlog : integer) : integer;
  function ntohl (netlong : u_long) : u_long;
  function ntohs (netshort : u_short) : u_short;
  function recv (s : SOCKET; buf : PChar; len, flags : integer) :
integer;
  function recvfrom (s : SOCKET; buf : PChar; len, flags : integer;
from : sockaddr; fromlen : integer) : integer;
  function select (nfds : integer; readfds, writefds, exceptfds :
fd_set; timeout : timeval) : longint;
  function send (s : SOCKET; buf : PChar; len, flags : integer) :
integer;
  function sendto (s : SOCKET; buf : PChar; len, flags : integer;
addrto : sockaddr; tolen : integer) : integer;
  function setsockopt (s : SOCKET; level, optname : integer; optval :
PChar; optlen : integer) : integer;
  function shutdown (s : SOCKET; how : integer) : integer;
  function _socket (af, struct, protocol : integer) : SOCKET;
  function gethostbyaddr (addr : PChar; len, struct : integer) :
PHostEnt; { hostent }
  function gethostbyname (name : PChar) : PHostEnt; { hostent }
  function getservbyport (port : integer; proto : PChar) : PServEnt; {
servent }
  function getservbyname (name, proto : PChar) : PServEnt; { servent }
  function getprotobynumber (proto : integer) : PProtoEnt; { protoent

Quote:
}

  function getprotobyname (name : PChar) : PProtoEnt; { protoent }
  function WSAStartup (wVersionRequired : word; lpWSData : LPWSADATA)
: integer;
  function WSACleanup : integer;
  procedure WSASetLastError (iError : integer);
  function WSAGetLastError : integer;
  function WSAIsBlocking : BOOL;
  function WSAUnhookBlockingHook : integer;
  function WSASetBlockingHook (lpBlockFunc : TFarProc) : TFarProc;
  function WSACancelBlockingCall : integer;
  function WSAAsyncGetServByName (HWindow : HWND; wMsg : u_int; name,
proto, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetServByPort ( HWindow : HWND; wMsg, port : u_int;
proto, buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetProtoByName (HWindow : HWND; wMsg : u_int; name,
buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetProtoByNumber (HWindow : HWND; wMsg : u_int;
number : integer;
                                      buf : PChar; buflen : integer) :
THandle;
  function WSAAsyncGetHostByName (HWindow : HWND; wMsg : u_int; name,
buf : PChar; buflen : integer) : THandle;
  function WSAAsyncGetHostByAddr (HWindow : HWND; wMsg : u_int; addr :
PChar; len, struct : integer;
                                  buf : PChar; buflen : integer) :
THandle;
  function WSACancelAsyncRequest (hAsyncTaskHandle : THandle) :
integer;
  function WSAAsyncSelect (s : SOCKET; HWindow : HWND; wMsg : u_int;
lEvent : longint) : integer;

function WSAMakeSyncReply (Buflen, Error : Word) : LongInt;
function WSAMakeSelectReply (Event, Error : Word) : LongInt;
function WSAGetAsyncBuflen (Param : LongInt) : Word;
function WSAGetAsyncError (Param : LongInt) : Word;
function WSAGetSelectEvent (Param : LongInt) : Word;
function WSAGetSelectError (Param : LongInt) : Word;

implementation

var
   fdSet : fd_set;

function FIONBIO (x, y : integer; t : u_long) : u_long;
begin
     FIONBIO := (IOC_IN OR ((IOCPARM_MASK shl 16) OR (x SHL 8) OR
(Y)));
end;

function WSAMakeSyncReply;
begin
     WSAMakeSyncReply := MakeLong (Buflen, Error);
end;

function WSAMakeSelectReply;
begin
     WSAMakeSelectReply := MakeLong (Event, Error);
end;

function WSAGetAsyncBuflen;
begin
     WSAGetAsyncBuflen := LOWORD(Param);
end;

function WSAGetAsyncError;
begin
     WSAGetAsyncError := HIWORD(Param);
end;

function WSAGetSelectEvent;
begin
     WSAGetSelectEvent := LOWORD(Param);
end;

function WSAGetSelectError;
begin
     WSAGetSelectError := HIWORD(Param);
end;

function accept;            external    'WINSOCK' index 1;
function bind;              external    'WINSOCK' index 2;
function closesocket;       external    'WINSOCK' index 3;
function connect;           external    'WINSOCK' index 4;
function ioctlsocket;       external    'WINSOCK' index 12;
function getpeername;       external    'WINSOCK' index 5;
function getsockname;       external    'WINSOCK' index 6;
function getsockopt;        external    'WINSOCK' index 7;
function htonl;             external    'WINSOCK' index 8;
function htons;             external    'WINSOCK' index 9;
function inet_addr;         external    'WINSOCK' index 10;
function inet_ntoa;         external    'WINSOCK' index 11;
function listen;            external    'WINSOCK' index 13;
function ntohl;             external    'WINSOCK' index 14;
function ntohs;             external    'WINSOCK' index 15;
function recv;              external    'WINSOCK' index 16;
function recvfrom;          external    'WINSOCK' index 17;
function select;            external    'WINSOCK' index 18;
function send;              external    'WINSOCK' index 19;
function sendto;            external    'WINSOCK' index 20;
function setsockopt;        external    'WINSOCK' index 21;
function shutdown;          external    'WINSOCK' index 22;
function _socket;            external    'WINSOCK' index 23;

function gethostbyaddr;     external    'WINSOCK' index 51;
function gethostbyname;     external    'WINSOCK' index 52;
function getprotobyname;    external    'WINSOCK' index 53;
function getprotobynumber;  external    'WINSOCK' index 54;
function getservbyname;     external    'WINSOCK' index 55;
function getservbyport;     external    'WINSOCK' index 56;

function WSAAsyncSelect;    external    'WINSOCK' index 101;
function WSAAsyncGetHostByAddr; external 'WINSOCK' index 102;
function WSAAsyncGetHostByName; external 'WINSOCK' index 103;
function WSAAsyncGetProtoByNumber; external 'WINSOCK' index 104;
function WSAAsyncGetprotoByName; external 'WINSOCK' index 105;
function WSAAsyncGetServByPort; external 'WINSOCK' index 106;
function WSAAsyncGetServByName; external 'WINSOCK' index 107;
function WSACancelAsyncRequest; external 'WINSOCK' index 108;
function WSASetBlockingHook; external    'WINSOCK' index 109;
function WSAUnhookBlockingHook; external 'WINSOCK' index 110;
function WSAGetLastError;    external    'WINSOCK' index 111;
procedure WSASetLastError;   external    'WINSOCK' index 112;
function WSACancelBlockingCall; external 'WINSOCK' index 113;
function WSAIsBlocking;     external     'WINSOCK' index 114;
function WSAStartup;        external     'WINSOCK' index 115;
function WSACleanup;        external     'WINSOCK' index 116;

end.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. BPW Graphics Library

2. Winsock.tpu; winsock.dll

3. winsock in pascal..

4. DBDesktop invokes Trumpet Winsock

5. BP7/DOS and Winsock

6. winsock

7. winsock unit

8. WINSOCK

9. winsock or tcp/ip

10. Using WINSOCK in Protected Mode

11. WINSOCK FOR TPW 1.5

12. Telling if a Winsock connection is established

 

 
Powered by phpBB® Forum Software