Thread: FD_SET trouble using winsock.

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    80

    FD_SET trouble using winsock.

    I find this kind of strange but when I use the FD_SET macro in my program everything compiles fine but when I run the executable it crashes.

    Code:
    SOCKET test;
    fd_set read_check;
    
    FD_SET(test, &read_check);
    Any suggestions why this happens ?

    EDIT: I'm using the mingw c/c++ compilers and Code::Blocks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Did you initialise the socket variable test?
    Did you FD_ZERO the set before using it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    80
    I thought I did, but when I created a new project just for testing it all worked perfectly. The trouble is in a socket class I'm writing so I have to double check the class code it seems.

    If it wasn't for your reply I would not have checked this because I was absolutely sertain I had initialized the socket and also FD_ZERO the set. Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 08:32 AM
  2. Winsock asynchronous socket + MessageBox() = trouble?
    By jmd15 in forum Networking/Device Communication
    Replies: 8
    Last Post: 02-07-2006, 02:50 PM
  3. Winsock Messaging Program
    By Morgul in forum Windows Programming
    Replies: 13
    Last Post: 04-25-2005, 04:00 PM
  4. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 12:11 PM
  5. winsock
    By pode in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-26-2003, 12:45 AM