Project: Physical Analytics server

Technologies: Linux, C++, Multithreading, Network Sockets, MySQL
My Responsibly: Design, Code

Description: This server provides a back end for the Physical Analytics iPhone app. Allowing iPhones to synch their workout data. Physical Analytics the iPhone fitness app I wrote had a network component, the app was designed to be a client to a server program that could manage the backup of data and sharing of data logged by the application. This meant that software could share training data between iPhones and could for example be sent to a trainer or downloaded onto PC software for analysis.
Technologies: Linux, C++, Multithreading, Network Sockets, MySQL
My Responsibly: Design, Code

Description: This server provides a back end for the Physical Analytics iPhone app. Allowing iPhones to synch their workout data. Physical Analytics the iPhone fitness app I wrote had a network component, the app was designed to be a client to a server program that could manage the backup of data and sharing of data logged by the application. This meant that software could share training data between iPhones and could for example be sent to a trainer or downloaded onto PC software for analysis.

To do this I decided to write my own server for a number of reasons including;

  • Time, At the time I was in the endeavour program and starting a business amounting to a roughly hundred hour week.
  • I was familiar with C++, Linux and Sockets.
  • I didn't have time to learn another method. It seems more difficult to write a server from scratch but at the time I was so incredibly busy that I didn't have time to learn a new technically to do the job.
So I wrote program in C++ on Linux it used MySQL for the database, and Sockets to connect to iPhones and was fully threaded. It listened on a set port waiting for connections when an iPhone connects it identifies it's self with it's unique ID a new connectionManager object is created on a different port in a new thread and the iPhone is moved to that port for the rest of the connection.

When the message is sent to the server from the iPhone the server adds a message to the messages spool. A parser object running on a separate thread process messages in the order they were added, parses the values and interacts with the database manager object which handles reading and writing to the database.

Conclusion
I was surprised how well it worked and how smoothly it ran but in hindsight, using what I have learned since;

  • I wouldn't have written it as a stand alone piece of software. It was the wrong tool for the job. I would use PHP or perhaps a web service to handle syncing.
  • Security is almost non existence. It did ask for a devices UID but did not authenticate that in any way. It also didn't securely control who was sharing data with who. Communication were also sent in the clear. If I was rewriting it I might use SSL for communications and to authenticate send the client random bytes that they would encode using a pad based on their password using MD5. As well the application would also be susceptible to format string and SQL injection attacks.