FD_SET trouble using winsock.

This is a discussion on FD_SET trouble using winsock. within the Networking/Device Communication forums, part of the General Programming Boards category; I find this kind of strange but when I use the FD_SET macro in my program everything compiles fine but ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 07:32 AM
  2. Winsock asynchronous socket + MessageBox() = trouble?
    By jmd15 in forum Networking/Device Communication
    Replies: 8
    Last Post: 02-07-2006, 01: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, 11:11 AM
  5. winsock
    By pode in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-26-2003, 12:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21