Thread: Making simple client-server program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715

    Making simple client-server program

    Hello people,
    I'm making simple client server program. I have done this before.
    I have two computers in home LAN and want to test it.
    Computer A on which server program is located has 192.168.0.2 IP address
    Computer B on which is client program has IP: 192.168.0.1.
    Aplication is simple and basically it just send/receive strings.
    Everything works OK if I on client side do something like this:
    Code:
    he = gethostbyname ("192.168.0.2");	
    server_adresa.sin_family = AF_INET;     
    server_adresa.sin_port = htons (PORT_NUM); 
    server_adresa.sin_addr = *( (struct in_addr * ) he->h_addr );
    But this solution require me to know server address in advance and to hard coded it.
    Is there any way, and API function (Windows) which can help me to do this dinamically.
    I know that is hard.
    Basically I want this:
    On Computer A I want to open port and listen, and on computer B when I start client program to try to connect to server over home LAN.
    I don't think there is a simple way to do this, but just want your advice.
    Thanks
    Last edited by Micko; 07-05-2007 at 02:24 AM.
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with simple socket client/server program
    By spencer88 in forum C Programming
    Replies: 6
    Last Post: 05-05-2009, 11:05 PM
  2. Server Architecture
    By coder8137 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-29-2008, 11:21 PM
  3. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  4. Commerical MMORPG Developer Opp
    By Th3Guy in forum Projects and Job Recruitment
    Replies: 19
    Last Post: 01-22-2007, 11:28 AM
  5. TCP/IP client & echo server
    By Jordban in forum C++ Programming
    Replies: 2
    Last Post: 06-06-2005, 06:39 PM