Thread: Close multiple sockets

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    930

    Close multiple sockets

    Is it ok close two sockets like this?
    The compiler telling me that the second one has no effect.

    Code:
    closesocket(client), (server);
    or the standard way:

    Code:
    closesocket(client);
    closesocket(server);
    Using Windows 10 with Code Blocks and MingW.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by Ducky View Post
    Is it ok close two sockets like this?
    The compiler telling me that the second one has no effect.

    Code:
    closesocket(client), (server);
    or the standard way:

    Code:
    closesocket(client);
    closesocket(server);
    That's because the first set of statements are equivalent to:

    Code:
    closesocket(client);
    server;
    Hence, no effect.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    930
    So we cannot close two sockets with one function.

    Thank you!
    Using Windows 10 with Code Blocks and MingW.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TCP Sockets: multiple clients - one server
    By Printisor in forum C Programming
    Replies: 4
    Last Post: 11-01-2007, 10:34 AM
  2. multiple connections via sockets
    By cope in forum Networking/Device Communication
    Replies: 7
    Last Post: 06-07-2007, 10:35 AM
  3. multiple UDP sockets with select()
    By nkhambal in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-17-2006, 07:36 PM
  4. Sockets, Multiple I/O
    By _Cl0wn_ in forum C Programming
    Replies: 3
    Last Post: 03-18-2003, 03:53 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM