将结构作为字符串从客户端发送到服务器 [英] Sending a structure as a string from client to server

查看:63
本文介绍了将结构作为字符串从客户端发送到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi


我使用Chilkat.com功能(客户端和服务器)构建了两个独立的项目,客户端将服务器发送到服务器(但它只发送给服务器)一个STRING)。我的问题是:



是否可以从客户端向服务器发送一个结构,其中包含不同类型的数据?

And如果我的项目只发送字符串,怎么办呢?



最好的问候。

Rania

解决方案

Quote:

是否可以从客户端向服务器发送一个结构,其中包含不同类型的数据?

当然有可能。它一直在发生:-)。





引用:

如果我的项目只发送字符串,怎么办呢?

你可以完全控制客户端和服务器应用程序,因此你甚至可以建立自己的发送/接收数据协议。但是,我会遵循其他人给出的好建议并查看序列化主题(例如,参见:在MSDN上引入XML序列化 [ ^ ])。


您应该以序列化数据格式发送数据。 Json或XML是一个好主意,但经常为您的框架提供一些简单的解决方案。



如果数据丢失或无效,请小心实现错误处理。

Hi
I've build two separate projects using Chilkat.com functions(client and server), in which the client sends information to the server (but it only sends it as a "STRING"). My question is:

is it possible to send a structure from the client to the server, which contains data of different types?
And if my projects only send strings, how can it be done ?

Best Regards.
Rania

解决方案

Quote:

is it possible to send a structure from the client to the server, which contains data of different types?

Of course it is possible. It happens all the time :-).


Quote:

And if my projects only send strings, how can it be done ?

You have full control on both the client and the server applications, hence you could even establish your own protocol for sending/receiving data. However I would follow the good advices other people gave and have a look at serialization topic (see, for instance: "Introducing XML Serialization" at MSDN[^]).


You should sent the data in a serialized data format. Json or XML is a good idea, but often gives your framework some easy-solution.

Be careful in implementing error handling if data is missing or invalid.


这篇关于将结构作为字符串从客户端发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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