Click here to Skip to main content
15,881,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
in c++, i m doing socket programming in Ubuntu environment,

at this stage i m trying this,

client side:
C++
do
{
  
   printf("Please enter the message:(Enter q for quit) ");
    bzero(buffer,256);
    fgets(buffer,255,stdin);
    n = write(sockfd,buffer,strlen(buffer));
    if (n < 0) 
         error("ERROR writing to socket");
    bzero(buffer,256);
    n = read(sockfd,buffer,255);
    if (n < 0) 
         error("ERROR reading from socket");
   if(buffer[0]=='q') 
     break;
   printf("%s\n",buffer);

}while(1) ;


server side:
C++
do{
     bzero(buffer,256);
     n = read(newsockfd,buffer,255);
     if (n < 0) error("ERROR reading from socket");
     printf("Here is the message: %s\n",buffer);
     if(buffer[0]=='q')    
        break;
    
    printf("Please enter the message:(Enter q for quit) ");
    bzero(buffer,256);
    fgets(buffer,255,stdin);
   
      n = write(newsockfd,buffer,strlen(buffer));
     if (n < 0) error("ERROR writing to socket");
   }while(1); 



now each one can send one message then wait for response to send more messages,
i want to make a client server , so that they can chat through multiple lines at once. just like, yahoo and facebook chats..

plz suggest me something.. thanx in advance....
Posted
Updated 29-Nov-11 5:15am
v2
Comments
Mohibur Rashid 2-Dec-11 4:25am    
Here is a thing for OP,

you cannot compare between yahoo messenger and Facebook chatting system. You must have to remember that Yahoo messenger that you install in your machine is a client but Facebook is not the client :) the client is the browser you are using.

 
Share this answer
 
Comments
Albert Holguin 30-Nov-11 0:00am    
That may be exactly what he's looking for (assuming it does work in Linux), shows the power of searching in CP before asking a question... +5
elgaabeb 30-Nov-11 10:27am    
This is a good aticle ... 5'd
If you are using Boost you can use
http://www.pion.org/projects/pion-network-library[^]

or
http://pocoproject.org/[^]

They have many examples also.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900