CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Posts
    6

    get hosts in my LAN listening on a specific port

    I am developing a network game in C under Linux, so the users in the LAN can play with each other. Therefore a server is running in each host, listening in a specific port.

    So a client must realize a scanning of all the hosts in the same LAN listening the port. I could use nmap, but nmap will yield too much information that I will have to compute with a pipe, isn't it??

    Please, let me know if you think the following idea is suitable.

    If I knew my own IP address, I would know the type of IP address, A B or C, and also I would know the part of the IP aimed for hosts. So using the socket system call “connect” to the specified port I am able to know all the hosts in my network offering this service.

    What do you think is better??

    Thank you very much!!!

  2. #2
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: get hosts in my LAN listening on a specific port

    Quote Originally Posted by suizVisual View Post
    I am developing a network game in C under Linux, so the users in the LAN can play with each other. Therefore a server is running in each host, listening in a specific port.
    The word "therefore" means that the second concept follows logically and ineluctably from the first, but if you mean "host" in the network sense, that is certainly not true here.

    A "server" should not be running on each host. Rather, a client should be running on each host that is playing the game, and all the clients should connect to a single well-known server on the LAN that coordinates game play, or otherwise gives out information needed to coordinate game play.

    For example, a minimal server might merely keep track of all current players, including IP number and port. When a new player connects, the new player gets the list, and all existing players are notified of the new player. The players can then conduct their own peer-to-peer communications.

    Mike

  3. #3
    Join Date
    Dec 2010
    Posts
    6

    Re: get hosts in my LAN listening on a specific port

    Hi Mike thank you very much!!! I was wrong with “therefore” sorry a lot.

    Where is supposed the server to be running?? Let's suppose there are three users in the LAN: A, B and C.

    If there is only one server, this server must always be running. Let's suppose the host A is the server. If user A shuts his/her computer down, B and C can not play anymore.

    This is the centralized approach. If we use a distributed approach all the users can play with each other, without the central server.

    What do you think!

    Thanks a lot!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured