本文整理汇总了C#中NetworkStream.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkStream.GetString方法的具体用法?C# NetworkStream.GetString怎么用?C# NetworkStream.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkStream
的用法示例。
在下文中一共展示了NetworkStream.GetString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunRepl
public void RunRepl (NetworkStream s)
{
string input = null;
while (!InteractiveBase.QuitRequested) {
try {
string error_string;
StringWriter error_output = (StringWriter)stderr;
string line = s.GetString ();
bool result_set;
object result;
if (input == null)
input = line;
else
input = input + "\n" + line;
try {
input = evaluator.Evaluate (input, out result, out result_set);
} catch (Exception e) {
s.WriteByte ((byte) AgentStatus.ERROR);
s.WriteString (e.ToString ());
s.WriteByte ((byte) AgentStatus.RESULT_NOT_SET);
continue;
}
if (input != null){
s.WriteByte ((byte) AgentStatus.PARTIAL_INPUT);
continue;
}
// Send warnings and errors back
error_string = error_output.ToString ();
if (error_string.Length != 0){
s.WriteByte ((byte) AgentStatus.ERROR);
s.WriteString (error_output.ToString ());
error_output.GetStringBuilder ().Clear ();
}
if (result_set){
s.WriteByte ((byte) AgentStatus.RESULT_SET);
StringWriter sr = new StringWriter ();
CSharpShell.PrettyPrint (sr, result);
s.WriteString (sr.ToString ());
} else {
s.WriteByte ((byte) AgentStatus.RESULT_NOT_SET);
}
} catch (IOException) {
break;
} catch (Exception e){
Console.WriteLine (e);
}
}
}