Thread: Server and client in the same program

  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,195
    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.

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-10-2009, 12:35 AM
  3. c program client server
    By steve1_rm in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-24-2008, 10:33 AM
  4. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 08:04 PM
  5. Server Client Messaging Program
    By X PaYnE X in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-04-2004, 05:20 PM