插座性能C ++或C# [英] Socket Performance C++ Or C#

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

问题描述

我必须写一个应用程序,本质上是一个代理服务器,以处理从服务器(Web浏览等),所有的HTTP和HTTPS请求。 。//www.mentalis:我知道很少C ++,我非常舒服编写C#中的应用程序功能。

I have to write an application that is essentially a proxy server to handle all HTTP and HTTPS requests from our server (web browsing, etc). I know very little C++ and am very comfortable writing the application features in C#.

我已经从的(C#插座代理),这似乎是做工精细的小型网页,但如果我去大网站如tigerdirect.ca并通过一对夫妇浏览层是非常缓慢,有时请求没有完成,我看到破碎的图像和JavaScript错误。这种情况与我们所有的供应商站点和其他内容沉重的网站。

I have experimented with the proxy from Mentalis (C# socket proxy) which seems to work fine for small webpages but if I go to large sites like tigerdirect.ca and browse through a couple of layers it is very slow and sometimes requests don't complete and I see broken images and javascript errors. This happens with all of our vendor sites and other content heavy sites.

颏使用HTTP 1.0,我知道是不是有效率,但应代理是慢?这是性能损耗的从使用代理可接受量?将HTTP 1.1做一个明显的区别?

Mentalis uses HTTP 1.0 which I know is not as efficient but should a proxy be that slow? What is an acceptable amount of performance loss from using a proxy? Would HTTP 1.1 make a noticeable difference?

将一个C ++代理大于一个在C#中更快?是颏代码只是效率不高?
。将我能够使用预制的C ++代理并导入DLL到C#,仍然可以得到不错的表现或会这个项目呼吁所有C ++?

Would a C++ proxy be much faster than one in C#? Is the Mentalis code just not efficient? Would I be able to use a premade C++ proxy and import the DLL to C# and still get good performance or would this project call for all C++?

对不起。如果这是显而易见的问题,但我以前没有做过网络编程

Sorry if these are obvious questions but I have not done network programming before.

修改在回答约书亚的问题:我不一定需要只要有一个好的执行了写有核心代理服务器自己,但就像我说我一直与颏未执行该试验良好。最终的应用程序需要安装从0手动配置一个安装在Windows PC /服务器上。

EDIT In response to Joshua's question: I don't necessarily need to write the core proxy server myself as long as there is a good implementation out there but like I said I have been experimenting with Mentalis which isn't performing that well. The final application needs to install on a Windows PC/Server from a single installer with 0 manual configuration.

我可以写所有必需的注册表编辑在安装程序,因为我有做到这一点之前在C#。

I can write all the necessary registry edits in the installer as I have done that before in C#.

更新我把Aaronaught的建议,看着改善颏'代码。我解决一个问题,所以它与HTTP 1.1允许它与Chrome和Firefox浏览器(Safari 4的Windows上,虽然崩溃代理出于某种原因)。

UPDATE I took Aaronaught's advice and looked into improving Mentalis' code. I fix a problem so it works with HTTP 1.1 allowing it to work with Chrome and Firefox (Safari 4 on Windows crashes the proxy though for some reason).

当我在Firefox和Chrome测试,我发现没有性​​能问题有哪些暗示这是一个IE浏览器的问题不是与代理问题。重置浏览历史记录设置的问题消失了。

When I tested in FireFox and Chrome I discovered the performance problems were not there which implied it was an IE problem not a problem with the proxy. After resetting the browsing history settings the problem went away.

谢谢大家!

推荐答案

您如何实际设计和代码的应用程序将让无限超过你选择平台的差别。

How you actually design and code the application is going to make infinitely more of a difference than the platform you choose.

如果您高效地设计服务器,它将是有效的。如果低效设计它,这将是低效的。有没有明显的优势,在选择C ++在C#或反之亦然......除非你不得不从头学习整个语言,这是一个巨大的负值(很难拿出一个很好的设计,当你几乎不认识的工具)。

If you design the server efficiently, it will be efficient. If you design it inefficiently, it will be inefficient. There's no clear advantage to choosing C++ over C# or vice versa... unless you'd have to learn the entire language from scratch, which is a huge negative (hard to come up with a good design when you barely know the tools).

事情你可能得理解这种类型的应用:

Things you'll probably have to understand for this type of application:


  • I / O完成端口

  • 线程池和多线程一般

  • 网络协议(包括HTTP,FTP,TCP等) - 尤其是对错误处理

  • 证书和签名/加密(用于SSL / HTTPS)

  • ...

  • I/O completion ports
  • Thread pools and multi-threading in general
  • Networking protocols (including HTTP, FTP, TCP, etc.) - especially for error handling
  • Certificates and signing/encryption (for SSL/HTTPS)
  • ...

老实说,你在这里谈论的是一个不平凡的事业。我的意思不是听起来过于消极,但什么让你觉得你可以做一个更好的工作,而不底层的网络协议和代理设计的一个广泛的知识?为什么不来看看颏代理的源代码,而不是看你是否能改善它,而不是试图从头开始编写自己的? 。肯定前者会比后者更容易

Honestly, you're talking about a non-trivial undertaking here. I don't mean to sound overly negative but what makes you think you can do a better job without an extensive knowledge of the underlying networking protocols and proxy design? Why not take a look at the Mentalis Proxy source code instead and see if you can improve it, rather than trying to write your own from scratch? Surely the former would be easier than the latter.

反正一个插座是一个插座; .NET插座并不比在Windows套接字纸一样薄的包装要多得多,所以性能是不是要在C ++明显的不同。

Anyway, a socket is a socket; .NET sockets are not much more than paper-thin wrappers over Windows sockets, so performance is not going to be noticeably different in C++.

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

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