You are currently viewing the BOOK Beginning Linux Programming, 3rd Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
i am new to socket programming...when i was trying the code given in the book for client-server model using socket programming, i faced a broken pipe error in the server program
--------------client.c-------------------
#include<sys/types.h>
#include<sys/socket.h>
#include<stdio.h>
#include<sys/un.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{ int sockfd;
int len;
struct sockaddr_un address;
int result;
char ch='A';
int main()
{
int server_sockfd,client_sockfd;
int server_len,client_len;
struct sockaddr_un server_address;
struct sockaddr_un client_address;
char ch;
read(client_sockfd,&ch,1);
ch++;
write(client_sockfd,&ch,1);
close(client_sockfd);
}
}
--------------------------------------------------------
when i run server in the background i get
server waiting
after this when i run client i get
oops:client:Success
[1]+ Broken pipe ./server
i am not being able to figure the error...plz help
Hi Octavius, did you manage to resolve this and if so, how? Thanks, Frank
Quote:
Originally Posted by octavius
i am new to socket programming...when i was trying the code given in the book for client-server model using socket programming, i faced a broken pipe error in the server program
--------------client.c-------------------
#include<sys/types.h>
#include<sys/socket.h>
#include<stdio.h>
#include<sys/un.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{ int sockfd;
int len;
struct sockaddr_un address;
int result;
char ch='A';
int main()
{
int server_sockfd,client_sockfd;
int server_len,client_len;
struct sockaddr_un server_address;
struct sockaddr_un client_address;
char ch;
read(client_sockfd,&ch,1);
ch++;
write(client_sockfd,&ch,1);
close(client_sockfd);
}
}
--------------------------------------------------------
when i run server in the background i get
server waiting
after this when i run client i get
oops:client:Success
[1]+ Broken pipe ./server
i am not being able to figure the error...plz help