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. HELP! Winsock problem about the select function...

HELP! Winsock problem about the select function...

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmintutorialquestion
2 Posts 2 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.
  • J Offline
    J Offline
    JoeZhang
    wrote on last edited by
    #1

    hi, guys, In my current Winsock-based TCP program, on the client side, after I send my request data packet to the Server side using the send socket function, I attempt to get the socket status to see if it has something to read using the select function, and the select function always return 0 meaning the time limit expired on some users' computers, but it's just fine on another users' computers. Why? Does anybody can tell me why and how to fix it? Thanks! here's the code... //... SOCKET sckClient = socket(AF_INET, SOCK_STREAM, 0); int nOne = 1; setsockopt(sckClient, IPPROTO_TCP, TCP_NODELAY, (char *)&nOne, sizeof(int)); // just_say_no struct sockaddr_in addr_to = { 0 }; //... connect(sckClient, (struct sockaddr *)&addr_to, sizeof(addr_to)); char *buf; //... send(sckClient, (const char *)((char*)buf), nDataToSend, 0); int nRetCode = ::select((int)sckClient + 1, &fdsRead, NULL, NULL, &tvTimeOut); if (nRetCode==0 ) { //ERROR: the time limit expired //Here's the problem! some computers meet the error, but some don't! WHY??? } recv(sckClient,(char *)buf,nDataToRead, 0); //...

    V 1 Reply Last reply
    0
    • J JoeZhang

      hi, guys, In my current Winsock-based TCP program, on the client side, after I send my request data packet to the Server side using the send socket function, I attempt to get the socket status to see if it has something to read using the select function, and the select function always return 0 meaning the time limit expired on some users' computers, but it's just fine on another users' computers. Why? Does anybody can tell me why and how to fix it? Thanks! here's the code... //... SOCKET sckClient = socket(AF_INET, SOCK_STREAM, 0); int nOne = 1; setsockopt(sckClient, IPPROTO_TCP, TCP_NODELAY, (char *)&nOne, sizeof(int)); // just_say_no struct sockaddr_in addr_to = { 0 }; //... connect(sckClient, (struct sockaddr *)&addr_to, sizeof(addr_to)); char *buf; //... send(sckClient, (const char *)((char*)buf), nDataToSend, 0); int nRetCode = ::select((int)sckClient + 1, &fdsRead, NULL, NULL, &tvTimeOut); if (nRetCode==0 ) { //ERROR: the time limit expired //Here's the problem! some computers meet the error, but some don't! WHY??? } recv(sckClient,(char *)buf,nDataToRead, 0); //...

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Does the second system receive the packets okay? Kuphryn

      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