Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

" getline(cin,stream) " gives segmentation fault error

807575May 26 2009 — edited Jun 4 2009
Hi

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2009
Added on May 26 2009
14 comments
1,113 views