GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Feb-2005, 12:07
Chris.Dev's Avatar
Chris.Dev Chris.Dev is offline
Junior Member
 
Join Date: Jan 2005
Posts: 48
Chris.Dev will become famous soon enough

Basic UNIX IPC and BSD Sockets


I wrote a proxy a few weeks ago for an app I use frequently where the client connects to the proxy and the proxy connects to the server.

What im trying to do is make the proxy get the server data then launch the client which will connect to the proxy.

CPP / C++ / C Code:
listen(sd1, 5);
printf("Listening on port 2346...\n");

      if((pid = fork()) == 0) {
        if((execl("program", "program", "-client", "127.0.0.1:2346", 0)) < 0) {
              printf("Error launching program");
              exit(0);
        }
      }

    sda = accept(sd1, (struct sockaddr *) &localgr, (&clilen));
              if(sda < 0) {
                  printf("There was an error connecting to the client.\n");
                  return 1;
              }
              else {
                  printf("Connection with the client has been established!\n");
                  printf("Connecting to the server...\n");
                  close(sd1);
              }

ETC...

it looks like it connects but then crashes imediately... Any suggestions?
  #2  
Old 22-Feb-2005, 16:15
nkhambal nkhambal is offline
Regular Member
 
Join Date: Jul 2004
Location: CA USA
Posts: 315
nkhambal is a jewel in the roughnkhambal is a jewel in the rough
Hello Chris,

You can block in child process till Server has finish fetching data in Parent process. Once server is finished fetching data, it can send a signal to child process via IPC which can then connect to server.

Check out IPC Message queues. You can exchange messages between any two different process using message queues. There are other methods as well but I prefer message queues. Cause it allows me to send any type of data (such as my own data structure) via message queue.

Following link will give you a headstart in message queue.

http://www.ecst.csuchico.edu/~beej/guide/ipc/

Thanks,
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic information about web hosting world priyanka Web Hosting Forum 19 12-Mar-2005 10:14
.o compile UNIX stuff ... help please! crq C++ Forum 5 28-Jan-2005 07:43
Access database and Visual basic programming confused_pig C++ Forum 0 11-Jan-2005 18:59
Which platform- NT or Unix? priyanka Web Hosting Forum 2 16-Feb-2004 07:54
Useful SSH / Unix commands JdS Web Hosting Forum 4 17-Jan-2003 15:20

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

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


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.