Simple UDP Socket - JSON
Mission:
To design and program two projects one to be a Sender and one to be a Receiver.
From the Sender to the Receiver you are to sent information as A) plain text and B) json encoded.
Background:
Previous exercises Simple (tcp) Sockets
Assignment A: JSON communication
- In Visual Studio 2019 Create a new solution 'ConsoleApp (.Net Core)', and name it e.g. 'PlainUDPReceiver'.
- Create a new Project 'ConsoleApp (.Net Core)', and name it e.g. 'JsonUDPReceiver'.
- Create a new Project 'ConsoleApp (.Net Core)', and name it e.g. 'JsonUDPSender'.
- In the JsonUDPSender Create a class 'UDPSender' with a method 'Start'.
- In the start method
- make an object of the car class e.g. 'Tesla, Green, JsonCar4' -- see / reuse model class from Simple (tcp) Sockets with JSON
- On the socket send a json-string i.e. Serialize the car object to a json-string and sent it as a Datagram.
- In the JsonUDPReceiver Create a class 'UDPReceiver' with a method 'Start'.
- In the start method
- Listen on port 11002 (or pick your own port number)
- When a Datagram is received - read from the Datagram a text string(Json) of the car and print it out.
- Decode the Json-string into a car object and print out the car-object.
-
- Run the sender and the receiver - and see the result.
- Commit and push
your
server-solution to a Git-Repository.
Assignment B: Broadcast messages
- Switch your network to use MGV2-DMU1 (MGV2-DMU2) - password = 'lanmagle'
- Modify your UDPSender to use a braodcast IP address i.e. new IPEndPoint( IPAddress.Broadcast, PORT-Number ).
- Start your UDPReceiver and see the result
- Make your neighbor start a UDPReceiver on the same port - can (s)he see the result ?
Assignment C: More Broadcast messages
- Still be at the MGV2-DMUx network.
- Make a UDPSender which broadcast out your name to port 11111.
- Make a UDPReceiver to collect all names in the class ie. receive a datagram and print out the name.
- Extra keep track at the names displayed so each name only is displayed once
Extra Assignment: Chat Service
- Back ground: see tcpChatServer
- Make the chat server / client to use UDP-server