// return general response code from server or -1 if 
no valid *numeric* 
// response was received. throws exSock() in case of non-recoverable error if strict==true
int response(istream& s, bool strict = true);

{
	int n=-1;
 // first 3 characters of server response is numeric - so read them at single step
	s >> n;
	if (n > 100)
 n /= 100;
	if (n == -1 || (n != 2 && n != 3) && strict) // something went wrong
 throw exSock();
 // skip the human-readable part of response we won't analyze or show it to user
	s.ignore(0, '
');
	return n;
}
int main(int argc, char* argv[])

{
 try
	{
		iosockinet smtp;
		smtp->connect(«smtp.somehost.ru», 25);
		// ignore initial server message - some servers will be quiet
		if (smtp->is_readready(5))
			response(smtp, false);
		smtp << «HELO « << smtp->localhost() << endl;
		response(smtp);
		smtp << «MAIL FROM: <» << argv[3] << «>» << endl;
		response(smtp);
		smtp << «RCPT TO: <» << argv[4] << «>» << endl;
		response(smtp);
		smtp << «DATA» << endl;
		response(smtp);
		smtp << «Hello from STL world!» << endl << «.» << endl;
		response(smtp);
		smtp << «QUIT» << endl;
		response(smtp);
		smtp->close();
	}
	catch(basic_ex& e)
	{
		cout << endl << «Fatal error: « << e.what() << «, code: « << e.code();
	}
...
}