Multiple servers on one network (winsock)

This is a discussion on Multiple servers on one network (winsock) within the Networking/Device Communication forums, part of the General Programming Boards category; Let's suppose that I have a basic network with 3 computers connected to each other via Ethernet. Two of those ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    40

    Multiple servers on one network (winsock)

    Let's suppose that I have a basic network with 3 computers connected to each other via Ethernet. Two of those computers wish to host my server program. The third computer wishes to run my client program to connect to one of those hosts. Is there some way to enumerate through any sockets actively listening for clients?

    The server program, in pseudocode, is:
    Code:
    WSAStartup()
    WSASocket()
    bind()
    listen()
    while (true) { accept() }
    The client program would be (pseudocode):
    Code:
    WSAStartup()
    WSASocket()
    se = getServerEnum()
    foreach (Server s in se) { print(s.id) }
    us = getUserSelection()
    connect(us)
    So basically I'm looking for something to plug in for my hypothetical getServerEnum() function.
    Is there such a thing, or do you just connect to whomever happens to be listening?

    Thanks in advance,
    -IsmAvatar

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    Well you could use ping to determine if a server machine is alive, but that doesn't guarantee a lot.
    - the server may have disabled ping
    - the server may not be running your service

    Even having established that a server is alive and running your service, and could accept a connection at time T1, it might not be the case at a later time T2.

    > or do you just connect to whomever happens to be listening?
    Pretty much.

    Most things seem to come with a list of servers, and then the user selects one to try.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. establishing a local area network (two servers and clients)
    By shrijeetp in forum Networking/Device Communication
    Replies: 3
    Last Post: 09-10-2005, 07:17 AM
  2. Determining Data Size For Network Send/Rec :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 6
    Last Post: 05-07-2002, 10:01 PM
  3. Replies: 2
    Last Post: 03-05-2002, 05:52 AM
  4. Winsock for network programming?
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-20-2002, 09:55 PM
  5. how to listen to multiple Network cards in one go?
    By C beginner in forum C++ Programming
    Replies: 0
    Last Post: 08-16-2001, 01:51 AM

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