C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 11-25-2008, 05:45 PM   #1
Registered User
 
Join Date: Aug 2006
Posts: 9
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.
smithx is offline   Reply With Quote
Old 11-25-2008, 09:30 PM   #2
Malum in se
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 3,188
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.
abachler is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with client server program... cprogczar C Programming 2 04-21-2009 07:56 PM
Chat Program Help? Paul22000 Networking/Device Communication 9 02-10-2009 12:35 AM
c program client server steve1_rm Networking/Device Communication 3 01-24-2008 10:33 AM
Where's the EPIPE signal? marc.andrysco Networking/Device Communication 0 12-23-2006 08:04 PM
Server Client Messaging Program X PaYnE X Networking/Device Communication 3 01-04-2004 05:20 PM


All times are GMT -6. The time now is 03:18 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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