Cst556 Distributed Applications for .NET with Mono 2 ...

cnSerialThreadSocket.fm

Course Review Notes

Cst556 Distributed Applications for .NET with Mono 2. Serialization, Threads and Sockets with .NET and C#

Distributed Applications for Windows ? T. Lindquist 2019

February 2019

Page 1

cnSerialThreadSocket.fm

Course Review Notes

2.a Motivation, Outcomes and References

2.a.1 Outcomes: Why Serialization, Threads and Sockets?

? How can a program running on one machine communicate with a program running on another machine (using Sockets)?

? How can a Socket's Input or Output Stream be used to migrate an instance of a User-Defined class, or Data across a network (or to/from a file)?

? How can a program running on one machine use Threads to provide a service to several programs/clients running on other machines?

? Outcomes - To be able to use the .NET framework classes and methods involved with IO and serialization to move primitive data or an object instance from one language runtime to another via sockets or a file. - To know how and when to use binary or XML serialization. - To know how to customize serialization in C# with .NET. - To know how to design and realize threaded socket programs in C#. - To know how to synchronize multiple threads so they may share data. To know how to communicate between several threads using delegates.

Distributed Applications for Windows ? T. Lindquist 2019

February 2019

Page 2

cnSerialThreadSocket.fm

Course Review Notes

2.a.2 Index to Pages with Example Programs

? Streams: Section 2.b.2 Basics of Stream Input and Output in .NET (System.IO)

? Deep Serialization: Section 2.b.8 Class Diagram for the Boat Example ? Controlling Serialization: Section 2.b.11 Custom Serialization of Nested

Objects ? Simple Sockets: Section 2.c.8 .NET Sample Socket Client and Server ? Threaded Server: Section 2.d.5 Other Threading Capabilities ? Threads Share Data: Section 2.d.7 C# .NET Monitors

Distributed Applications for Windows ? T. Lindquist 2019

February 2019

Page 3

cnSerialThreadSocket.fm

Course Review Notes

2.b Serialization in C# with .NET 2.b.1 Basics of Serialization in C#

? Writing the state of an object to a stream for persistence or transporting. - Unlike Java, C# does not support transporting the code/behaviors (.class files). - Allows saving an object to a file and re-reading it from the file. - Allows communicating objects via sockets to other running programs.

? Allows saving objects in binary, Soap, or XML. ? Binary and Soap Serialization of an object

- All properties and fields are serialized. Use binary when you wish to replicate the object and transport or recover its entire state.

? XML Serialization of an object - Only the public properties and fields are converted to the stream.

? Serialization involves using the Binary, Soap or XML formatter with - Attributes [Serializable] and [NonSerialized] - Possibly implementing the ISerializable interface, for customization.

Distributed Applications for Windows ? T. Lindquist 2019

February 2019

Page 4

cnSerialThreadSocket.fm

Course Review Notes

2.b.2 Basics of Stream Input and Output in .NET (System.IO)

? Store and retrieve primitive data as binary values - int, bool, string, byte, short, char, float, double, decimal - use classes BinaryReader, and BinaryWriter

? See the example program to read and write data to a binary file: - BinaryRWExample.cs

? Store and retrieve primitive data as text values - use classes StreamReader and StreamWriter to read and write files - use classes StringReader and StringWriter to read/write a string buffer

? See the example program to read and write data to a text file: - StreamRWExample.cs

? Directory and File information can be manipulated with the classes - Directory, DirectoryInfo, File, FileInfo - See the example program that lists the contents of a directory - DirectoryInfoExample.cs - Download all three examples with an Ant build file: streamIO.jar

Distributed Applications for Windows ? T. Lindquist 2019

February 2019

Page 5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download