WSACancelBlockingCall() in 95's wsock32.dll vs. NT 4.0

WSACancelBlockingCall() in 95's wsock32.dll vs. NT 4.0

Post by Richard Braman » Tue, 25 Feb 1997 04:00:00



Has anyone seen similar behavior on Win95?  Know if MS has made an
official statement in regards to this?

thanks,

--rich

/* the following code works correctly (in my opinion) over NT 4.0
 * wsock32.dll but does not work over win95 wsock32.dll.  What happens
 * on 95 is that after the first recvfrom() fails with WSAEINTR, the
 * next two recvfrom() calls also fail immediately with the same error
 * (note: myblockinghook() is never called again.)  NT 4.0 will
 * correctly call recvfrom() 3 times and will call myblockinghook()
 * in the background waiting for the user to cancel each call.
 */

#include <windows.h>
#include <iostream.h>
extern "C" {
#include <stdio.h>
#include <conio.h>

Quote:}

int WINAPI myblockinghook(void);

int main()
{
        SOCKET s;
        WSADATA data;
        int ret;
        struct sockaddr_in addr;

        WSAStartup(0x0101, &data);
        int (WINAPI *fp)(void) = myblockinghook;
        if(!WSASetBlockingHook(fp))
                cout << "Blocking Hook installed.\n";

        char buffer[256];

        for(int i=0;i<3;i++) {
                cout << "iteration: " << i+1 << endl;

                s = socket(PF_INET, SOCK_DGRAM, 0);
                cout << "socket() returns: " << s << "\t\t\tWSAGetLastError():
"
                                << WSAGetLastError() << endl;

                addr.sin_family = AF_INET;
                addr.sin_addr.s_addr = 0;
                addr.sin_port = 0;

                ret = bind(s, (LPSOCKADDR)&addr, sizeof(addr));
                cout << "bind() returns: " << ret << "\t\t\tWSAGetLastError():
"
                                << WSAGetLastError() << endl;

                cout << "Hit a key to cancel recvfrom():...\n";
//              recv() fails the same way....
//              ret = recv(s, buffer, sizeof(buffer), 0 );
                ret = recvfrom(s, buffer, sizeof(buffer), 0, NULL, NULL);
                cout << "recvfrom() returns: " << ret <<
"\t\t\tWSAGetLastError(): "
                                << WSAGetLastError() << endl;

                ret = closesocket(s);
                cout << "closesocket() returns: " << ret <<
"\t\tWSAGetLastError(): "
                                << WSAGetLastError() << endl;          

        }

        WSAUnhookBlockingHook();
        WSACleanup();
        return 0;

Quote:}

int WINAPI myblockinghook()
{
        cout << "\\\r|\r/\r";
        if(_kbhit()) {
                _getch();
                cout << "WSACancelBlockingCall() returns: " <<
WSACancelBlockingCall() << "\tWSAGetLastError(): " << WSAGetLastError() <<
endl;        
        }
        return 0;
Quote:}

 
 
 

1. WSOCK32.DLL vs WS2_32.DLL

Hi there,

  I am writing a 32-bit networking program which should run in WIN NT and

95.

I am confused whether I should call WSOCK32.DLL (32-bit winsock 1 APIs) or

WS2_32.DLL (32-bit winsock 2 APIs). I know that 95 has no build-in

WS2_32.DLL

and we have to install it manually. Besides WSAEnumProtocols of WS2_32.DLL

seems NOT work in 95. Any body can tell which one is suitable for my

program?

And is there any good books for programming NT/95 networks?

  Thanks.

Moore

2. FA: CD32 & SX-1 SCALA WORKSTATION WS500

3. winsock.dll & wsock32.dll current version #'s and location

4. A Typographical Question

5. wsock32.dll with visual basic 4.0

6. NI-CAD batteries

7. WSOCK32.DLL Trace/Spy Facility - wsock32.zip (0/1)

8. Stripping Letterhead from Outgoing Messages

9. WSOCK32.DLL Trace/Spy Facility - wsock32.zip (1/1)

10. Works on '95 but not on NT 4.0

11. Accessing COM ports using Win32's and/or MSCOMM control in Windows 95/NT 4.0.

12. DLL not found in NT 4.0... works fine in 95...?

13. how replace Winsock.dll with Wsock32.dll