[prog] a simple chat program using cnaiapi

Aslı gosalyn at gmail.com
Sat Oct 15 10:45:35 EST 2005


hey,
i'm trying to write a simple chat program using the cnaiapi library. I
have two clints talking to each other. What the server does is taking
the 1st client's message and delivering it to the second one, and also
taking the 2nd client's message and delivering it to the 1st one.
The problem I'm having is about the await_contact function.
I wrote this control at the beginning of my server side code:
......
connection conn1,conn2;

conn1 = await_contact((appnum) atoi(argv[1]));
    if(conn1 < 0)
        exit(1);
    else
        (void)printf("Chat connection with the first client is established.\n");

    conn2 = await_contact((appnum) atoi(argv[1]));
    if(conn2 < 0)
        exit(1);
    else
        (void)printf("Chat connection with the second client is
established.\n");

after the compilations, I'm running the server program as   .\chatserver 23000
and the client programs as                                            
 .\chatclient localhost 23000
so, I'm using three different terminals to test my application.

The problem is this:
After running the server application, I execute the first client's
application, and I get both these messages although I havent executed
the second clients application yet.
Chat connection with the first client is established
Chat connection with the second client is established

I couldnt understand why the second await_contact function does not
wait for my second client to make a connection..

Thanks in advance for your help..

Aslı..


More information about the Programming mailing list