Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: menu change Pin
Anurag Gandhi23-May-07 0:06
professionalAnurag Gandhi23-May-07 0:06 
Question__loctotime_t function in Win32 Pin
bouli22-May-07 21:17
bouli22-May-07 21:17 
AnswerRe: __loctotime_t function in Win32 Pin
Hamid_RT22-May-07 21:34
Hamid_RT22-May-07 21:34 
AnswerRe: __loctotime_t function in Win32 Pin
_AnsHUMAN_ 22-May-07 22:43
_AnsHUMAN_ 22-May-07 22:43 
GeneralRe: __loctotime_t function in Win32 Pin
bouli22-May-07 22:46
bouli22-May-07 22:46 
QuestionRe: __loctotime_t function in Win32 Pin
David Crow23-May-07 4:11
David Crow23-May-07 4:11 
AnswerRe: __loctotime_t function in Win32 Pin
bouli23-May-07 4:13
bouli23-May-07 4:13 
QuestionSocket Connection problem in Windows XP System from VC++ Pin
ledallam22-May-07 21:14
ledallam22-May-07 21:14 
I am using the following function to find out whether I can connect to a particular IP address(for ex:3.205.202.6 etc...) in VC++.
This function returns TRUE on Windows 2000 if the given IP address is communicating one. But on Windows XP system it always returns FALSE (However I can still say ping to this IP :- 3.205.202.6 from DOS command prompt. It replies correctly).
Can anyone please help me to root cause this issue in Windows XP system. Is this socket API not valid on Win XP system? On Win2000, it always gives me the correct status.

BOOL IsOnline(const CString &strIPAddr)
{

SOCKET tmpSocket;
struct sockaddr_in SClient;
u_long argp;
fd_set stReadFDS;
fd_set stWriteFDS;
fd_set stExceptFDS;
struct timeval stTimeOut;
int nSelectReturn;
DWORD nTicks;
DWORD nTickStart;
//create a socket
tmpSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) ;

if (tmpSocket == INVALID_SOCKET)
{
return FALSE;
}

// make the socket non blocking
argp = 1L; // non zero enables nonblocking mode
if (ioctlsocket(tmpSocket, FIONBIO, (u_long FAR *) &argp) == SOCKET_ERROR)
{

closesocket(tmpSocket);
return FALSE;
}

// connect to the given IP address
SClient.sin_family = AF_INET;
SClient.sin_port = htons(502);
SClient.sin_addr.s_addr = inet_addr(strIPAddr);

int nLastErr;
if (connect(tmpSocket, (sockaddr *) &SClient, sizeof(sockaddr_in)) == SOCKET_ERROR)
{

nLastErr = WSAGetLastError();

if (nLastErr != WSAEWOULDBLOCK)
{

closesocket(tmpSocket);
return FALSE;
}

nTicks = 500;
nTickStart = GetTickCount();
nSelectReturn = SOCKET_ERROR;

int ic = 0;
while (nSelectReturn <= 0 && (GetTickCount() - nTickStart) < nTicks)
{

// clear all sockets from FDS structure, then put our socket into the socket descripter
FD_ZERO(&stReadFDS);
FD_ZERO(&stWriteFDS);
FD_ZERO(&stExceptFDS);
FD_SET(tmpSocket, &stReadFDS);
FD_SET(tmpSocket, &stWriteFDS);
FD_SET(tmpSocket, &stExceptFDS);

// set a timeout of 1 second
stTimeOut.tv_sec = 1;
stTimeOut.tv_usec = 0;

nSelectReturn = select(-1, &stReadFDS, &stWriteFDS, &stExceptFDS, &stTimeOut);

if (nSelectReturn == SOCKET_ERROR)
{
nLastErr = WSAGetLastError();
if (nLastErr != WSAEINPROGRESS)
{
closesocket(tmpSocket);
return FALSE;
}
}

}

if (nSelectReturn <= 0 || stWriteFDS.fd_count == 0)
{
closesocket(tmpSocket);
return FALSE;
}
}
closesocket(tmpSocket);
return TRUE;

}


Thanks
AnswerRe: Socket Connection problem in Windows XP System from VC++ Pin
KarstenK22-May-07 21:19
mveKarstenK22-May-07 21:19 
GeneralRe: Socket Connection problem in Windows XP System from VC++ Pin
ledallam22-May-07 21:31
ledallam22-May-07 21:31 
AnswerRe: Socket Connection problem in Windows XP System from VC++ [modified] Pin
Mark Salsbery23-May-07 6:22
Mark Salsbery23-May-07 6:22 
QuestionXML Parsing Pin
g_sandipan22-May-07 21:03
g_sandipan22-May-07 21:03 
AnswerRe: XML Parsing (another point of view) Pin
Joan M23-May-07 0:13
professionalJoan M23-May-07 0:13 
GeneralRe: XML Parsing (another point of view) Pin
g_sandipan23-May-07 1:43
g_sandipan23-May-07 1:43 
AnswerRe: XML Parsing Pin
James R. Twine23-May-07 3:51
James R. Twine23-May-07 3:51 
QuestionCOM+ Dll Registration Failed!! Pin
Rane22-May-07 20:32
Rane22-May-07 20:32 
AnswerRe: COM+ Dll Registration Failed!! Pin
Hans Dietrich22-May-07 21:05
mentorHans Dietrich22-May-07 21:05 
GeneralRe: COM+ Dll Registration Failed!! Pin
Rane22-May-07 23:58
Rane22-May-07 23:58 
AnswerRe: COM+ Dll Registration Failed!! Pin
Paresh Chitte23-May-07 0:12
Paresh Chitte23-May-07 0:12 
QuestionRe: COM+ Dll Registration Failed!! Pin
David Crow23-May-07 4:13
David Crow23-May-07 4:13 
QuestionHow to develop an XML file using VC++ [modified] Pin
kunal.tawde22-May-07 20:12
kunal.tawde22-May-07 20:12 
AnswerRe: How to develop an XML file using VC++ [modified] Pin
Nibu babu thomas22-May-07 20:15
Nibu babu thomas22-May-07 20:15 
AnswerRe: How to develop an XML file using VC++ Pin
Cedric Moonen22-May-07 20:19
Cedric Moonen22-May-07 20:19 
GeneralRe: How to develop an XML file using VC++ Pin
kunal.tawde22-May-07 22:40
kunal.tawde22-May-07 22:40 
AnswerRe: How to develop an XML file using VC++ Pin
Hamid_RT22-May-07 21:05
Hamid_RT22-May-07 21:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.