Server and client in the same program

This is a discussion on Server and client in the same program within the Networking/Device Communication forums, part of the General Programming Boards category; Hi, maybe this is a silly question, I hope to be clear: what I want is to have a server, ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    10

    Server and client in the same program

    Hi, maybe this is a silly question, I hope to be clear: what I want is to have a server, and once a connection is established (by using accept and then fork) use the connect() function to connect to another application using the parameters that the client that connect to my server gave me. I hope its clear and I don't think is something very complicated, but I need an example code.

    If its not clear don't hesitate to ask. Thanks in advance.

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    yes, you want to have your program be teh server for one application, adn the client for another, this is entirely possible. You just set up 2 seperate sockets, one is a listenign socket and one is a connectign socket. Typically they are done is different threads, but they can be done in a single thread.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with client server program...
    By cprogczar in forum C Programming
    Replies: 2
    Last Post: 04-21-2009, 07:56 PM
  2. Chat Program Help?
    By Paul22000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 02-09-2009, 11:35 PM
  3. c program client server
    By steve1_rm in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-24-2008, 09:33 AM
  4. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 07:04 PM
  5. Server Client Messaging Program
    By X PaYnE X in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-04-2004, 04:20 PM

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