Click to See Complete Forum and Search --> : What's the difference between NT 4.0 SP6a and w2k?


yigal
March 21st, 2000, 08:54 AM
Hi

I wrote a network application which works o.k.
on NT SP4 but on NT SP6a or w2k it doesnt work.

the symptom is : loss of FD_WRITE notification
after calling to WSAEnumNetworkEvents.

(cant call WSAEventSelect for the second time
on the same socket to get FD_WRITE notification)

can any one tell me what can be the cause?
what are the improvement when updating from SP6a to w2k concerning ws2_32.dll (winsock2)?

best regards.

Rick Leinecker
April 27th, 2000, 01:15 PM
Can you give me the syntax that you're using? I'll work through it and see if I can get an answer.

yigal
April 30th, 2000, 06:44 AM
Hi

here is a sample:

#include "stdafx.h"
#include
/* This sample code should iterate forever,instead it stuck on wait function.
right on the second iteration.

Important! :This applies only on win 98/2k/NT SP6 with vc++6.0 SP3 SDK3.1
It works o.k(?) on win NT 4.0 SP4
After the call to WSAEnumNetwrokEvents there is a loss of FD_WRITE notification.
and no more FD_WRITE notification can be received.
The folowing IP address is valid but can be replaced.
*/
int main(int argc, char* argv[])
{
SOCKET hSocket ;
SOCKADDR_IN SockAddr_In;
WSAEVENT NetworkEvent;
WSANETWORKEVENTS NetEventStruct ;
WSADATA wsd;
WORD wVersionRequested;
unsigned long ret_val;

wVersionRequested = MAKEWORD( 2, 2 );

if(WSAStartup(wVersionRequested,&wsd)!=0)
{

printf("Unable to start socket,\n");
printf("WS2_32.DLL not fond");

return 0;
}

if ( LOBYTE( wsd.wVersion ) != 2 ||
HIBYTE( wsd.wVersion ) != 2 ) {
WSACleanup( );
return 0;
}
SockAddr_In.sin_family = AF_INET;
SockAddr_In.sin_port = htons(23);
SockAddr_In.sin_addr.s_addr = inet_addr("132.70.1.6");// already network byte ordered

NetworkEvent = ::WSACreateEvent ();

hSocket = WSASocket(AF_INET, SOCK_STREAM, 0,NULL, 0, WSA_FLAG_OVERLAPPED);

if( WSAConnect(hSocket,(SOCKADDR*) &SockAddr_In, sizeof(SOCKADDR),NULL,NULL,NULL,NULL) == SOCKET_ERROR){

ret_val = GetLastError();

printf("unable to connect\t%d\n",ret_val);
return 0;
}


while(1)
{
if(ret_val = ::WSAEventSelect(hSocket, NetworkEvent, (FD_WRITE | FD_CONNECT) )== SOCKET_ERROR)
{
ret_val = WSAGetLastError();
printf("unable to perform select\t%d\n",ret_val);
}


printf("");// place a breakpoint here.

::WSAWaitForMultipleEvents(1, &NetworkEvent, FALSE, INFINITE, FALSE);

::WSAEnumNetworkEvents(hSocket,NetworkEvent, &NetEventStruct );
if(NetEventStruct.lNetworkEvents & FD_WRITE)
{
if(NetEventStruct.iErrorCode [FD_WRITE_BIT]== 0)
{
send(hSocket,"Hello",6,0);
Sleep(1000);
printf("%i\n",NetEventStruct.lNetworkEvents );
}
}
}

return 0;
}