Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows Socket Problem

Windows Socket Problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++csscomsysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QuickDeveloper
    wrote on last edited by
    #1

    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

    stefanmihaimogaS A 2 Replies Last reply
    0
    • Q QuickDeveloper

      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

      stefanmihaimogaS Offline
      stefanmihaimogaS Offline
      stefanmihaimoga
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      • Q QuickDeveloper

        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

        A Offline
        A Offline
        abbiyr
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups