Click here to Skip to main content
12,069,894 members (66,937 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ Ubuntu Sockets
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 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 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
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 1 Dec 2011
Copyright © CodeProject, 1999-2016
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