" getline(cin,stream) " gives segmentation fault error
807575May 26 2009 — edited Jun 4 2009Hi
In our application, we have a client and a server. Client and server communicate from network with inetd services. server listens the port with fd_set and get the the string with " select " as a command line argument. everything looks fine in communication but when the client sent a string over the network and server tries the read with getline(cin,stream ), application throws a segmentation fault error.
Code:
.
.
.
struct timeval t;
t.tv_sec=60;
t.tv_usec=0;
fd_set rset;
FD_ZERO(&rset);
FD_SET(STDIN_FILENO, &rset);
if(select(2, &rset,NULL,NULL,&t) == 0)
return NULL;
getline(cin, stream); *//application crashes here*
.
.
.
How can we solve this error ?
thanks for your kindly answers.
regards
aykut