Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Stopping ReadStdIn() function
Re: Stopping ReadStdIn() function [message #57045 is a reply to message #57043] Mon, 17 May 2021 18:24 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello again Oblivion, I like the tiemout approach. here is what I did :
String ReadCmd(int timeout)
{
	String r;
	int time = msecs();
	
	while(msecs(time) < timeout){
		int c = 0;
		int n = read(STDIN_FILENO, (char*) &c, 1);
		if(c == '\n')
			break;
		if(n > 0) {
			r.Cat(c);
			time = msecs();
		}
	}
	return r.GetCount() ? r : String::GetVoid();
}

It now work perfectly. Thanks for your precious help !

[Updated on: Mon, 17 May 2021 18:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: static
Next Topic: my TCP client/server don't work correctly
Goto Forum:
  


Current Time: Sun Jun 08 13:29:36 CEST 2025

Total time taken to generate the page: 0.04371 seconds