WCF VS.插座 [英] WCF VS. Sockets

查看:22
本文介绍了WCF VS.插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在游戏开发场景中,WCF 或 .NET Sockets 哪个更有效,更值得推荐.

I would like to know which of WCF or .NET Sockets is the more efficient and the more recommended in a game developpment scenario.

以下是游戏的不同部分:

Here are the different parts of the game :

-在互联网上播放的客户端/服务器通信

-a client/server communication to play on the internet

-本地网络上的点对点.

-peer to peer on local network.

我想知道您将在这些部件上使用哪种技术(两个都使用 wcf,两个都使用套接字,一个使用 wcf,另一个使用套接字......)以及为什么(如果可能).

I would like to know which technology you would use on these parts (wcf on both, socket on both, wcf on one and socket on the other...) and why, if possible.

所涉及的游戏对通信频率要求不高(每秒3-4次就足够了).

The game involved doesn't require a high communication frequency (3-4 per second is enough).

推荐答案

WCF 的目的是为了节省开发人员为不同的传输协议编写代码,它具有大量的特性,所以它比 Sockets 慢.加上 WCF 是面向服务的应用程序.我不认为游戏属于这一类.

The purpose of WCF is to save developers writing code for different transport protocols and it has large number of features so thats why it is slower than Sockets. Plus WCF is for service oriented applications. I dont think Games fall into this category.

但是正如您提到的,每秒只有 3-4 个请求,WCF 可能是更好的选择,因为它非常灵活并且可以节省大量开发时间.

But as you mention only 3-4 requests per second, WCF might be a better option as its very flexible and will save a lot of development time.

几点:

以 net* 开头的绑定旨在​​用于 .NET 应用程序之间.(客户端和服务器 WCF)
如果其中任何一个不是 WCF:您只能使用不以网络前缀开头的绑定.BasicHttpBinding、WSHttpBinding 等.这些比 net* 绑定慢得多,因为有很多开销.

The bindings that start with net* are meant to be used between .NET applications. (Both client and server WCF)
If any of the one is not WCF: You can only use the bindings that does not start with a net prefix. BasicHttpBinding, WSHttpBinding etc. These are much slower than the net* bindings as lot of overhead is there.

您可以继续使用 NetPeerTcpBinding 并使用它一段时间.它还支持双工通信.

You can go ahead with NetPeerTcpBinding and play with it for a while. It also supports duplex communication.

以下是一些对 P2P 有用的链接:

Here are some useful links for P2P:

使用 WCF 和 .NET Framework 3.5 进行对等编程
http://blogs.interknowlogy.com/2009/08/05/building-a-really-simple-wcf-p2p-application

这篇关于WCF VS.插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆