Differences

This shows you the differences between two versions of the page.

Link to this comparison view

osp:project:assignment [2017/01/09 11:42]
vlad.traista [Server revisions]
osp:project:assignment [2017/01/10 17:36] (current)
vlad.traista [Server revisions]
Line 10: Line 10:
   * Make sure that your team is registered [[http://​ocw.cs.pub.ro/​courses/​osp/​project/​team-choice|here]].   * Make sure that your team is registered [[http://​ocw.cs.pub.ro/​courses/​osp/​project/​team-choice|here]].
   * A single team member must upload the assignment. The team members should be mentioned in the README file.   * A single team member must upload the assignment. The team members should be mentioned in the README file.
 +  * The assignment has to be presented to the OSP team on **January 16th, 2017**, at **19:00**, in **PRECIS 703**. An assignment that is not presented will have a penalty of 1 point (out of 10).
  
 ==== General description ==== ==== General description ====
Line 26: Line 27:
 ==== Server revisions ==== ==== Server revisions ====
  
-This section will contain all the changes and bug fixes applied ​in the Python server code:+This section will contain all the changes and bug fixes applied ​to the Python server code:
  
   * **07.01.2017**   * **07.01.2017**
Line 35: Line 36:
           ---           ---
           >     ​server.bind(("",​ 4000))           >     ​server.bind(("",​ 4000))
 +          </​code></​spoiler>​
 +  * **09.01.2017**
 +    * fixed an issue that did not close the sockets when the remote end gracefully or forcefully closes the connection (e.g WiFi interface goes down). These changes are reflected in the server_experimental.py file which was added in the archive with the server code.
 +          <spoiler Diff><​code>​
 +@@ -160,12 +160,26 @@
 +         buf = b''​
 +         ​running = True
 +         while running:
 +-            aux_buf = self.socket.recv(4096)
 ++            try:
 ++                aux_buf = self.socket.recv(4096)
 ++            except Exception as e:
 ++                running = False
 ++                print("​Client disconnected..."​)
 ++                try:
 ++                    clients.remove(self)
 ++                    self.socket.close()
 ++                except Exception as e:
 ++                    print("​Server encountered following error: %s" % str(e))
 + 
 +             if len(aux_buf) == 0:
 +                 buf += b'​\0'​
 +                 ​running = False
 +                 ​print("​Client exiting..."​)
 ++                try:
 ++                    clients.remove(self)
 ++                    self.socket.close()
 ++                except Exception as e:
 ++                    print("​Server encountered following error: %s" % str(e))
 +             else:
 +                 buf += aux_buf
           </​code></​spoiler>​           </​code></​spoiler>​
  
Line 135: Line 167:
 === Task 6: Service reconnect (1p) === === Task 6: Service reconnect (1p) ===
  
-Add a broadcast receiver component which reconnects the service when the internet comes back online (if previous state was logged in).+Add a broadcast receiver component which reconnects the service when the internet comes back online (if previous state was logged in). If the user was previously logged in, the reconnect procedure should restart the login procedure (the JSON messages).  
 + 
 +<note warning>​ 
 +When implementing this receiver, it will most likely listen to events caused by the change of network connectivity state (WiFi interface goes down or up). However, when a WiFi interface goes up it transitions multiple times into the CONNECTED state which means that the receiver will receive that event multiple times. **The reconnect procedure needs to be done only one time once the WiFi interface is up.** 
 +</​note>​ 
 + 
  
  
osp/project/assignment.1483954945.txt.gz · Last modified: 2017/01/09 11:42 by vlad.traista
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0