TCPclient和WinSock [英] TCPclient and WinSock

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

问题描述

我有一个使用WinSock编写的VB6客户端和服务器,一切正常.

我正在开发.NET应用程序(Visual Studio 2008).
我可以使用TCPclient作为客户端来连接WinSock中的服务器吗?

I have a VB6 client and server written using WinSock and everything works fine.

I am developing a .NET application(Visual Studio 2008).
Can I use TCPclient as client to connect to server in WinSock?

推荐答案

是的,绝对可以.您只需要开发应用程序级协议,并且客户端和服务器端都可以进行匹配.您需要确保不同的类型(托管和非托管)以相同的方式进行序列化和反序列化.

在这些不同技术中执行此操作的方法之一是将序列化减少为相同大小的原始类型的序列,并以二进制形式传递它们.由于几乎所有系统都将IEEE 754标准用于浮点类型,并且将两个补码用于整数类型.并且由于您可以对序列化文本使用相同的编码,因此所有数据都将正确解释.您也可以交换文本消息,但是您需要在两边进行相同的文本生成和解析,在复杂的解析(即使您仅解析数字)的情况下,效率可能不高.它可以是XML,JSON或其他任何内容.

请参阅:
http://en.wikipedia.org/wiki/Application_layer [ http://en.wikipedia.org/wiki/IEEE_floating_point [ http://en.wikipedia.org/wiki/Two%27s_complement [
Yes, absolutely. You only need to develop your application-level protocol and match is on both client and server sides. You need to make sure that your different types (managed and unmanaged) serialize and deserialize in an identical way.

One of the ways to do it in these different technologies is to reduce serialization to a sequence of primitive types of the same size and pass them in their binary form. As nearly all systems use IEEE 754 standard for floating-point types and two''s complement for integer types; and because you can use the same encoding for serialized texts, all the data will be interpreted correctly. You can also exchange text messages, but you would need to have identical text generation and parsing on both sides, might be not very efficient in case of complex parsing (even if you merely parse numbers). It could be XML, JSON, or anything else.

Please see:
http://en.wikipedia.org/wiki/Application_layer[^],
http://en.wikipedia.org/wiki/IEEE_floating_point[^],
http://en.wikipedia.org/wiki/Two%27s_complement[^].

—SA


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

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