Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Ubuntu socket
hi,
in c++, i m doing socket programming in Ubuntu environment,
 
at this stage i m trying this,
 
client side:
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:
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 29-Nov-11 5:49am
Edited 29-Nov-11 6:15am
v2
Comments
johny10151981 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Albert Holguin at 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 at 30-Nov-11 10:27am
   
This is a good aticle ... 5'd
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 1 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100