【发布时间】:2012-02-18 06:46:46
【问题描述】:
我想知道如何使用 WCF 服务而不是套接字 .. 发送命令 .. 有人告诉我它比创建客户端-服务器应用程序更强大 我的申请关于
//this function runs in its own thread
private void Job(object o)
{
Socket client = (Socket)o;
NetworkStream stream = new NetworkStream(client);
StreamReader sr = new StreamReader(stream);
try
{
string cmd = null;
while ((cmd = sr.ReadLine()) != null)
{
Console.WriteLine(cmd);
string[] command = cmd.Split('<');
switch (command[0])
{
case "root":
fmc.root();
break;
case "explore":
fmc.Explore(command[1]);
break;
case "new_folder":
fmc.NewFolder(command[1]);
break;
case "hidden":
fmc.HiddenChecked(command[1]);
break;
case "delete":
fmc.Delete(command[1]);
break;
case "properties":
if (command[1] == "single")
{
fmc.SingleProperties(command[2]);
}
else if (command[1] == "multi")
{
fmc.MultiProperties(command[2]);
}
else
{
fmc.DriveProperties(command[2]);
}
break;
case "pastefromcopy":
fmc.PasteFromCopy(command[1], command[2]);
break;
//case "confirm":
// break;
default:
Console.WriteLine(cmd);
break;
}
}
}
catch { client.Close(); stream.Dispose(); sr.Dispose(); }
}
所以你有任何教程可以接近我的应用程序.. 执行命令.. 或者你是否可以给我写一个简单的客户端-服务器 WCF .. 以同样的方式解决它。在此先感谢:)
【问题讨论】: