Windows Socket Problem
-
hi i am implementing SMTP in MFC for sending mails.if i specify the correct mail server name(eg: mail.yahoo.com) i get the response from the server immediately.However if i specify invalid mail server name, the application hangs & control returns after 20 seconds. ABC() //calls Connect function as given below { return Connect((SOCKADDR*)&sockAddr, sizeof(sockAddr)); } BOOL CSMTPSocket::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen) { return (connect(m_hSocket, lpSockAddr, nSockAddrLen) != SOCKET_ERROR); //problem is while calling this Windows Socket function. } i need to reduce the time to check for invalid mail server name to less than 20 seconds.how is it possible?? "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!" -- modified at 5:22 Thursday 6th April, 2006
-
hi i am implementing SMTP in MFC for sending mails.if i specify the correct mail server name(eg: mail.yahoo.com) i get the response from the server immediately.However if i specify invalid mail server name, the application hangs & control returns after 20 seconds. ABC() //calls Connect function as given below { return Connect((SOCKADDR*)&sockAddr, sizeof(sockAddr)); } BOOL CSMTPSocket::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen) { return (connect(m_hSocket, lpSockAddr, nSockAddrLen) != SOCKET_ERROR); //problem is while calling this Windows Socket function. } i need to reduce the time to check for invalid mail server name to less than 20 seconds.how is it possible?? "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!" -- modified at 5:22 Thursday 6th April, 2006
You can put that "connect(...)" method in a worker thread, and set an aditional timeout for that. I think that, when it's searching for an invalid server, it will always delay for several seconds. That's way it goes! Sorry! Good luck!
-
hi i am implementing SMTP in MFC for sending mails.if i specify the correct mail server name(eg: mail.yahoo.com) i get the response from the server immediately.However if i specify invalid mail server name, the application hangs & control returns after 20 seconds. ABC() //calls Connect function as given below { return Connect((SOCKADDR*)&sockAddr, sizeof(sockAddr)); } BOOL CSMTPSocket::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen) { return (connect(m_hSocket, lpSockAddr, nSockAddrLen) != SOCKET_ERROR); //problem is while calling this Windows Socket function. } i need to reduce the time to check for invalid mail server name to less than 20 seconds.how is it possible?? "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!" -- modified at 5:22 Thursday 6th April, 2006
Hi there. You could try using the gethostbyname function to validate the host name when it is entered. This way you could issue a warning if an ip address cannot be determined for the thost name and you would not be resolving hostnames during the connect call. Cheers