C#中的套接字编程:发送文本和字节 [英] Socket Programming in C#: Sending text and bytes

查看:71
本文介绍了C#中的套接字编程:发送文本和字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个涉及套接字编程的项目. SQL查询通过Send()以文本形式发送.在插入图像的情况下,查询以及图像的字节流必须一起发送.

I''m doing a project which involves socket programming. The SQL queries are send as text through Send(). In case of inserting an image the query as well as the byte stream of the image has to be send together. Is there any way 2 do this?

推荐答案

套接字对发送的内容一无所知:它只关心将数据字节从一个进程准确地移动到另一个进程.

如果需要发送多个数据,则需要将其封装在一个类中,对其进行序列化,然后在另一端进行反序列化,或者开始告诉收件人您将要发送哪种信息.

抱歉,就是这样!
A Socket knows nothing about what you are sending: it is just concerned in accurately moving bytes of data from one process to another.

If you need to send multiple data, then either you need to encapsulate it in a class, serialise it, and de-serialise at the other end, or start telling the recipient what kind of information you are about to send.

Sorry, but that''s the way it goes!


这篇关于C#中的套接字编程:发送文本和字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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