在Visual C ++ 2010中编写TCP/IP聊天应用程序 [英] Writing TCP/IP chat application in Visual C++ 2010

查看:158
本文介绍了在Visual C ++ 2010中编写TCP/IP聊天应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我决定学习Visual C ++,并试图通过读书和编写简单的程序来学习.现在,我正要了解TCP/IP.我想构建一个简单的聊天程序,以便您可以在服务器和客户端之间进行交谈.

我不知道MFC或CLR是否更适合此类应用程序.我知道CLR是托管的,并且您需要.NET来运行这些应用程序.这也意味着MFC通常会更快.编写tcp/ip应用程序时,我还缺少其他哪些优点/缺点?

如果我想通过tcp/ip编写聊天服务器+客户端,有人可以解释一下哪个更容易使用吗?从我的谷歌搜索,似乎MFC不是我想要做的一个很好的选择.我应该使用CLR吗?另外,有什么好的资源来学习如何在CLR中制作此程序?

So, I have decided to learn Visual C++ and am trying to learn by reading a book + making simple programs. I am now at a point where I want to learn about TCP/IP. I want to build a simple chat program, so you can talk between a server and client.

I don''t know if MFC or CLR are better for such application. I understand CLR is managed and you need .NET to run these applications. This also means MFC will generally be faster. What other pros/cons am I missing for these when writing a tcp/ip application?

Can someone please explain which would be easier to use if I wanted to write a chat server + client over tcp/ip? From my google search, it seems MFC is not a good option for what I want to do. Should I use CLR? Also, any good resources for learning how to make this program in CLR?

推荐答案

没有偏见很难回答,我也不想引发一场火焰大战.

我认为,.NET更加容易,您需要的手工工作更少,需要更多的了解. MFC很老,对我来说,它已经过时了. .NET充满了现代思想. MFC和Windows API具有很多遗留问题,包括遗留错误. .NET非常清晰.有些库是基于Windows遗留的,并且存在遗留问题(例如System.Windows.Forms,它不是ISO或EMCA标准的一部分,但是由于Mono软件,它可以移植到许多系统中;在Mono上运行我的Windows应用程序而无需重新编译).

CLR已成为ISO和ECMA标准;图书馆的基本部分; MFC…甚至不提它.

是的,.NET有时比MFC和本机Windows慢,但这主要是因为它是Windows上的额外一层.当Microsoft从头开始开发Singularity OS时( http://en.wikipedia.org/wiki/Singularity_(operating_system) [< ^ ]),目标是安全和性能被完全忽略了.但是,在衡量性能时,它击败了Windows,甚至在某些方面甚至超过了Linux.那是沉重的遗产.奇异性基于直接位于HAL上的纯CLR.

此外,我希望Windows会逐渐退出市场,但是.NET不会终止.将.NET用作新系统的基础有不同的方向. MFC甚至都不是生存之选.

(顺便说一下,我个人在原始Windows API级别上进行了非常广泛的开发.对于UI,即使我尝试使用MFC进行开发,我什至没有考虑MFC -它可以工作(但是,我广泛使用了STL).我使用了Delphi.而是加上原始的Windows API.)

让我们看看其他专家是否有不同的看法.我必须承认我几乎以自己的方式做所有事情...

—SA
It''s hard to answer without any bias, and I don''t want to sparkle a flame wars.

In my opinion, .NET is much easier, you need less manual work, more understanding. MFC is very old, to me, it''s obsolete. .NET is full of modern ideas. MFC and Windows API has a lot of legacy, including legacy bugs. .NET is very clear. Some libraries are based on Windows legacy and carry legacy problems (such as System.Windows.Forms, it''s not a part of ISO or EMCA standard, nevertheless it''s done portable to many systems, thanks to Mono software; I run my Windows applications on Mono without recompilation).

CLR is made ISO and ECMA standard; fundamental parts of the library too; MFC… don''t even mention it.

Yes, .NET is sometimes slower than MFC and native Windows, but this is mostly because it is an extra layer over windows. When Microsoft developed Singularity OS from scratch (http://en.wikipedia.org/wiki/Singularity_(operating_system)[^]), the goal was security and performance was completely neglected. Nevertheless, when performance was measured, it beat Windows and in some criteria even Linux. That is a weight of heavy legacy. Singularity is based on pure CLR sitting directly on HAL.

Besides, I hope that Windows will gradually leave the scene, but .NET is not planned for termination; there are different directions where .NET is put as a basis for new systems. MFC is not a candidate for survival even remotely.

(By the way, I personally developed very extensively at the level of raw Windows API. For UI, I did not even consider MFC even though I tried to develop with MFC — it works (however, I used STL extensively). I used Delphi instead. Plus raw Windows API.)

Let''s see if other experts say different opinions. I must admit I do almost everything in my own way…

—SA


这篇关于在Visual C ++ 2010中编写TCP/IP聊天应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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