Sending information over a socket in C #

I have created two programs in C # and I am sending simple strings through sockets. This is normal at the moment, but in the near future I will need to send more complex objects, such as objects down sockets and ultimately files.

What steps will I take for this? What is the purpose of socket / thread buffers? Sorry if I'm a little vague.

+3
source share
5 answers

If you send objects, you have to be very careful what you do and how you plan to use these objects on the other end. All properties must be serialized. If you have a lot of data in these topics, you can use binary serialization instead.

Also, check out the guidelines posted here: MSDN Serialization Principles

If you intend to send objects, you may want to look at the options for .Net Remoting or WCF Services, if applicable. Rolling your own socket handlers and then using them for complex operations takes a lot of time and pain, especially if you haven't done it yet.

+1
source

, , .

XML.

+1

- XML, , . . , ( .NET) JavaScriptSerializer, , , .

0

. [Serializable] . .

0

First of all, in any situation of the community, it should be borne in mind that everything you send must be able to serialize and serialize so that it can sort through the communication channel. Then you must consider that the connection has a delay (its not instantaneous), and then the fact that it can fail.

After that, you review the protocols and technology to enable this.

0
source

Source: https://habr.com/ru/post/1744169/


All Articles