简体   繁体   English

我如何使用WCF服务而不是套接字客户端服务器应用程序?

[英]how do i use WCF service instead of socket client-server application?

im wondering about how to use WCF service instead of sockets .. to send commands .. someone told me its more powerful than creating a client-server application my application about 我想知道如何使用WCF服务而不是套接字..发送命令..有人告诉我它比创建我的应用程序中的客户端服务器应用程序更强大

  • send/receive Commands 发送/接收命令
  • chat 聊天室
  • file transfer in my application i have to create at least two sockets on two ports .. one for (chat/commands) and one for fileTransfer .. 我的应用程序中的文件传输我必须在两个端口上创建至少两个套接字..一个用于(聊天/命令),另一个用于fileTransfer ..

     //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(); } } 

    so do you have any tutorial that would be close to my application.. to execute commands .. or if you can write me a simple client-server WCF .. that solve it the same way . 所以,您有没有接近我的应用程序的教程..执行命令..或是否可以给我写一个简单的客户端-服务器WCF ..来解决该问题。 thanks in advance :) 提前致谢 :)

  • there are really so many articles out on the web for making a chat service using wcf. 网上确实有很多文章可以使用wcf进行聊天服务。 It really depends on the level of what you want to make and how much you would like to learn. 这实际上取决于您想做的水平以及您想学多少。 I recommend you to go through a few of these videos here first to get the feel for wcf. 我建议您首先在这里浏览其中一些视频以了解WCF。

    Then look through these to find an example of what you would like to create. 然后浏览这些内容以找到您想要创建的示例。

    Have fun creating your service. 祝您创建服务愉快。

    The following link would be a good starting point. 以下链接将是一个很好的起点。 It details how to write a client server chat application in WCF. 它详细介绍了如何在WCF中编写客户端服务器聊天应用程序。

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM