DMU 2015 - 3. semester - oeadm15edD, oeadm15eiC

Weekly plan for Programming
 - please notice: this plan does not include all exercices / project work (normal wednesday and friday)

Theme: Socket programming  - Go to week: 34, 35, 36, 37

Sidst ændret: 2016.09.07

 

Uge 34

Goals for this week:

  • you should get a knowledge of simple distribution using socket, including knowledge of what is behind the client-server architecture and what a protocol involves related to this subject.
  • you should get programming experience making simple distributed client-server solutions using socket and simple self-defined protocol.

 

 
Dag Tidspunkt Emne Literature / Exercises
Torsdag 08:15 -

Network Programming with Socket

Example of socket client and socket server
- The essentials
- Design improvement on server with separation of managing client (Client Handler class)

Testing the server can be done using Telnet witch also can be run from the command prompt
- start the command prompt
- Then started: TELNET ip port
- Where ip and port specified corresponding to the configured server's IP address and port

.Net app(**) kap 4.4 (Socket)
- look also later in the week schedule for further reading

Slides om socket part 1 (nokn)

Example of a simple socket server and client
Example of a socket echo server and client

Programs for testing socketconnections:
Telnet_win98 - gui telnet klient

PuTTY - telnet & ssh klient
Program for testing socket tekst communikation - client / server 
 

  Problem solving with support from the teacher
- Discuss and compare, and help each other, but be sure even that code individually
you are expected to work with socket assignment 1-6
Exercices about socket server and socket-client
- 15:30  possibly review of exercise 3+4 from last session (one/more students present solutions)
 
 
 
(*) Core C# and .NET, Stephen C. Perry - see Fronter
(**) .Net Application Development with C#..., Hanspeter Mössenböck - see Fronter
(***) C# To the point -.., Hanspeter Mössenböck -   - see Fronter
Additional material for those who wish more reading material about socket:
An Introduction to Socket Programming in .NET using C# - CodeProject
Socket Code Examples   (MSDN)
Using TCP Services  (Socket server and klient - MSDN)
How to C# Socket programming  (csharp.net-informations.com)
Network socket - Wikipedia, the free encyclopedia

 
Additional material for those who wish more reading material about threads
Multithreaded Programming Using C# - CodeProject

MSDN
-Thread Class

-Threading Objects and Features
-Thread Pooling
-Timer
-Monitor
-Interlocked
-ReaderWriterLock

 

 

Preliminary
 

Uge 35

Goals for this week:

  • You are able to create a socket server that can communicate with multiple clients with an appropriate design.
  • You have knowledge of how you can broadcast to multiple clients and understanding of synchronization needs.
  • You are able to use observable pattern for low coupling including knowing the isues about GUI event activated from a threads

Preparation: please before meeting studdy materials of delegates / event, observer and threads, which at least in part you should be familiar with from the 1st years of studdy.

We will use part of the time to look at and discuss design - in the Socket projects you will find slides / pdf descriptions which will be the starting point - you will also finished coded solutions correspondingly to the design.

 
Dag Tidspunkt Emne Literature / Exercises
Torsdag 08:30 - Summarizing on socket server & client
 
Kodeeksempel på trådet server   - opgave 4 løsning
  Summarizing? about threads and synchronization
 


- Threads and special issues with GUI

Core C# (*) kap 13.1 (Thread intro)
.Net app(**) kap 4.3.1-4.3.3
(Thread)
Slides about threads and synchronization - (Samme på dansk)

ObserverPattern_Tråde_og_Gui_Winform_og_WPF
Tråde-og-GUI  (the core substance - the trick in the above)
 
     
  Design Considerations
- The first tentative attempts at further improvements in the treatment of client (server-side)
- separation of communications and business logic
SocketEchoComandBased (examples for separating communication and bussiness logic)
Contains tex file with content and also PowerPoint presenting the design considerations / effects
Contains:
- SocketServerCmdBasedStatic
- SocketServerCmdConnected
- SocketServerCmdDisconnected_V01
  - Proxy pattern  (same interface on server and klient) Slides om Proxy mønster
Eksempel på brug af proxy-mønster til echoservice'en fra tidligere
Elements will also be included in tne next example
 
  - Design with windows and console client

- Design with continued communication without blocked thread on the server (using of session)
The client examples do not take the final design step
- To create a generic class for socket communication and use that interface for proxy
- They are therefore just based on what we still woud call "Remote Facade"
- You may drop the facade classes when programming the client projects and instead use classes from "SocketEchoServiceLibrary".
 

SocketEchoComandBased (examples for separating communication and bussiness logic)
Contains tex file with content and also PowerPoint presenting the design considerations / effects
Contains:
- SocketServerCmdBasedStatic
- SocketServerCmdConnected
- SocketServerCmdDisconnected_V01
  Problem solving with support from the teacher
- Discuss and compare, and help each other, but be sure even that code individually
you are expected to work with socket assignment 5-6

Try to refactor your solution seperating the (business) logic from the communication on the server and if posibly thnen use the proxy pattern when making the client.
 
Exercices about socket server and socket-client 

 

 

12:15 Summarizing? about delegate/event & observer

- In generel about elegate,

- Observer pattern using med delegate / event

 

 

C# to the point (***) kap 11.1 about delegater
C#(*) kap 3.7 (Delegates)
Delegater examples 

ObserverPattern
ObserverPattern_CascadeEvent

Exstra reading from wikipedia (publish/subscribe):
http://en.wikipedia.org/wiki/Publish/subscribe
 

  Socket-chatserver design: Broadcasting
- push / observer
Examples of design opportunities:
Chat server design in step towards the observer-pattern
 
  Exercise contionued (socket 1-6)

If you are finish with the socket exercise 1-6 (refactoring using proxy pattern and seperating comm. and logic) you could make the game (exercise 6) for a shared game for more than one client. You might also try to make it posibly to run the game only connecting for send one request and getting one response - keeping the state on either serverside or client side.

You might also try to make a chatserver of your own design using socket.
 

 
14:30?- 15:30  possibly review of exercise 5+6 from last session (one/more students present solutions)
 
 
 
(*) Core C# and .NET, Stephen C. Perry - see Fronter
(**) .Net Application Development with C#..., Hanspeter Mössenböck - see Fronter
(***) C# To the point -.., Hanspeter Mössenböck -   - see Fronter
Additional material for those who wish more reading material about socket:
An Introduction to Socket Programming in .NET using C# - CodeProject
Socket Code Examples   (MSDN)
Using TCP Services  (Socket server and klient - MSDN)
How to C# Socket programming  (csharp.net-informations.com)
Network socket - Wikipedia, the free encyclopedia

 
Additional material for those who wish more reading material about threads
Multithreaded Programming Using C# - CodeProject

MSDN
-Thread Class

-Threading Objects and Features
-Thread Pooling
-Timer
-Monitor
-Interlocked
-ReaderWriterLock

 

Uge 36

Goals for this week:

  • You will have sufficient knowledge and experience with socket and threads to solve problems in the project 1.
  • That you get sufficient knowledge of threads to make a simple client that can both handle both traffic from the GUI to the server and from the server to the GUI in parallel.

Preparation: please have previously made you quite clear on what you may lack of knowledge about threads in relation to the needs of the project 1.
 

Dag Tidspunkt Emne Literature / Exercises
Mandag 08:15 - Follow up on  exercises from last week

Follow up on Socket-chatserver design: Broadcasting
- push / observer
 



Examples of design opportunities:

Chat server design in step towards the observer-pattern
  Thread pattern / design templates (follow up)

- common resource

- producer-consumer

- observer (event)
 

Slides about threads and synchronization - (Samme på dansk

Synchronizing/locking - design with resource-monitor and thead-method objekt 
Trådeksempel10_TrådOgResourceMonitor

Simple producer-consumer example - design follow up
Trådeksempel_Parkeringshus_wait_notify (korrekt behandling)
ObserverPattern_Parkeringshus 

ObserverPattern_Tråde_og_Gui_Winform_og_WPF 
Tråde-og-GUI   (the core substance - the trick in the above)
 

  Follow up on design templates for client side - remote facade / proxy
- separation of business logic (includning remote connection) and user interface
Look the following project in SocketEchoComandBased
- SocketClientMedRemoteFasade_ConsolApplikation
- SocketClientMedRemoteFasade_WindowsApplication
- SocketEchoServiceLibrary here seperated project
      business and clientservice as facade and using proxy pattern

Look at the following project in Chat server design in step towards the observer-pattern
- ChatServerDesign_05_NoLock
 
  Simple client witch can send and recieve at the same time parallel (multithreaded)
- Possibly programming of simple chat-client in class
- Multiple "return types" / asynchronous returns

Discussion of posibly solutions for at chatservice / mailservice
- push versus pull solutions / continous connect vesus only connectet for one request and response
 
Based on code from SocketEchoServiceLibrary and ChatServerDesign_05_NoLock


Program witch can be used as som test-server, can be used for testing the client dialog
Program for testing texst communication onr socket connection 
 
  Exercise for the day
- make a simple WPF chat client with sepperated send and recieve textbox for a chatserver

Try to make a simple chatserver (using a pull approcah) where you can participate in the chat without being connecet all the time but can use a request for retrieving chat messages instead of broadcast directly to only connected clients.
You can keep mesages at server in one collection (or more) - type depending of how you want the functionality
 

You might use the Program for testing texst communication onr socket connection as a server for manuel testing the client.
14:30 - 15:30 Possibly. summarizing and student(s) presentation of solutions for the exercies
 
 
 
(*) Core C# and .NET, Stephen C. Perry - see Fronter
(**) .Net Application Development with C#..., Hanspeter Mössenböck - see Fronter
(***) C# To the point -.., Hanspeter Mössenböck -   - see Fronter
Additional material for those who wish more reading material about socket:
An Introduction to Socket Programming in .NET using C# - CodeProject
Socket Code Examples   (MSDN)
Using TCP Services  (Socket server and klient - MSDN)
How to C# Socket programming  (csharp.net-informations.com)
Network socket - Wikipedia, the free encyclopedia


 
Additional material for those who wish more reading material about threads
Multithreaded Programming Using C# - CodeProject

MSDN
-Thread Class

-Threading Objects and Features
-Thread Pooling
-Timer
-Monitor
-Interlocked
-ReaderWriterLock

 

Uge 37
Goals for this week:
  • You will have knowledge and experience with simple HTTP client request and simple HTTP server response

Preparation: Read about HTTP on wiki (se link in plan) - you might also install fiddler (se link in plan) before lecture

 

Dag Tidspunkt Emne Literature / Exercises
Torsdag 08:15 - A bit more about protocols (we will be looking a bit on http)  primary read about GET and the examples http://en.m.wikipedia.org/wiki/Http#Technical_overview (read briefly before lecture)
http://en.m.wikipedia.org/wiki/Http#Example_session  (read before lecture)


Eventual take a short look for statuscodes for HTTP request here:
-
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes - link inserted after lecture

Independent tools for monitoring http communication
http://www.telerik.com/download/fiddler 
This tools will also be THE TOOL for testing WebAPI for the web programming, specialy for testing WebAPI - so it will be a good idea to be familary with it


You can find alternative tools working on a single browser - for example is here plugin for chrome. You might take a explore of these if you want.
Live HTTP Headers (Tools for monitoring http communication in google chrome)
https://chrome.google.com/webstore/detail/live-http-headers/iaiioopjkcekapmldfgbebdclcnpgnlo 

Programmer til test af socketforbindelser:
Telnet_win98 - gui telnet klient

Program for testing texst communication onr socket connection
 

  Use of  WebClient for HTTP client communikation 
- web request 
 
WebClientDemoConsoleApplication.zip
  Problem solving with support from the teacher
- Discuss and compare, and help each other, but be sure even that code individually  
Exercises with socket and the http protocol
 
Exercises using socket and the HTTP protokol - (Samme på dansk)

 

 - 15:30 Possibly. summarizing and student(s) presentation of solutions for the exercies