Close multiple sockets

This is a discussion on Close multiple sockets within the Networking/Device Communication forums, part of the General Programming Boards category; Is it ok close two sockets like this? The compiler telling me that the second one has no effect. Code: ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Location
    France
    Posts
    747

    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);
    Compiler MSVC++ 2010 with Code::Blocks.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    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
    Location
    France
    Posts
    747
    So we cannot close two sockets with one function.

    Thank you!
    Compiler MSVC++ 2010 with Code::Blocks.

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, 06:36 PM
  4. Sockets, Multiple I/O
    By _Cl0wn_ in forum C Programming
    Replies: 3
    Last Post: 03-18-2003, 02: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

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