Thread: Dumb question time - Winsock & accept()

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    Dumb question time - Winsock & accept()

    I'm pretty sure I know the answer to this, but I'm VERY new to Winsock.

    I'm building the server app and everything works fine until it gets to the accept() call. At that point, it just hangs. There is no client trying to connect. So, I'm guessing the hanging is because of that.

    Because I've been through Johnnie's Winsock tutorial and a couple others, and the problem is replicated in all of their code AND mine, I'm thinking it's because it's getting stuck looking for a client, but none is there.

    Sorry if this is elementary. I'm an admitted complete Winsock idiot.

    Jason

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    There are several solutions on the Win32 platform. One solution is a worker thread. Another solutions is AcceptEx().

    Kuphryn

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    accept() waits until there is a client so it would hang.

    Use asynchronous sockets or threads if you want to do something else while it is waiting.

  4. #4
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    You could use select() and put the waiting socket in an fd_set
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Thanks, guys.

    I'm going to hit up MSDN tonight and study up on the suggestions you've made.

    Jason

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    you could create a client program to connect to the localhost in a common port.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorry for a dumb question.
    By Vanished in forum C++ Programming
    Replies: 7
    Last Post: 11-23-2002, 12:39 PM
  2. winsock question
    By the Wookie in forum C++ Programming
    Replies: 12
    Last Post: 10-17-2002, 02:18 AM
  3. dumb question...
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-28-2002, 10:35 AM
  4. time function question
    By heat511 in forum C++ Programming
    Replies: 5
    Last Post: 01-03-2002, 02:23 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM