Posted by: Shary GUO on: 18/04/2009
Exercise 5: Binding sockets in a chat room
1. Using any familiar programming language environment, what do you know about sockets (network) programming?
2. Define some terms.
3. How is a socket bound to a port number and what is the role of the operating system on the server end?
4. Investigate a simple chat client/server system. Look at some program code and describe how it works with multiple users.
Types of databases
Database servers have long been the client/server arena for development.
Flatfile
The flat file database, is usually just a text file. It can suit many applications whereby the database’s to function like a rolodex. The records can be delimited, non-delimited or position delimited. The delimited records can be by CSV (comma-quote) or a Tab character in the text.
Relational DBMS
The relational model has advantages of “one to many” between tables and the use of simultaneous updates. Many are ODBC/SQL compliant, allowing communication across data sources/servers.
Object-oriented OODBMS
The object oriented model has data objects which are encapsulated by classes that have pre-defined characteristics. Such as a player, room or container object in a MOO. Objects added to the database automatically acquire (inherit) the characteristics of their class. These data are accessible only through messages which they recognise. ZOPE uses an OODBMS inside its core.
Database servers can use Thick or Thin clients. In a thick client like a modern Web browser, the client does much of the work, and so is relatively large and complex. A thin client is simple and light as the server handles most of the work, but can be network intensive.
2- and 3-tier database models
The 2-tier database model is a standalone application with data tightly bound, and includes many mainframe and workgroup database systems. Microsoft Access, as an example, may have all actions take place within a single Visual Basic application and the data may be in a separate or integrated file.
The 3-tier model is more popular for business, where the database backend is an Enterprise Relational Database such as Sybase or Oracle – with generally no direct access to the database. A Middleware component (API, controls or scripts) does most of the work in controlling access, building relational database tables and tracking changes. The clients are either thin, a Web browser, or a custom application – and of more than one type. The API support usually includes Perl, C, Java and Python, as well as Web submission forms, e.g. MyCSU and the CSU E-box system.
The advantages of the 3-tier database model are load distribution; transparency (changes at one level transparent at other levels, e.g. New client or backend); the ease of building custom application, business and data rules; as well as security controlled at the middleware layer.
Client/server database design issues
Consider . . .
The number of users
1. How will the system scale? Does it need to?
2. What’s your timeline?
3. What kind of output do you need?
4. Paper forms, web, wireless devices?
5. Will your application serve all needs?
Security Issues
1. Where is your security coming from?
2. Who needs access to what?
3. Need for agility in your code base.
4. Will you need to migrate? (Yes, you will!)
5. Do you need to add specialized applications?
Database case study: PHP and MySQL
Since over three million PHP/MySQL open-source relational model and web-based database systems are over the Internet, let us taker a closer look at this popular system – as we can learn how many of the other systems operate, in similar ways.
PHP
PHP is at http://php.net. The PHP engine works well with the Apache Web server – and a MySQL server is also needed. PHP files end in .php; this triggers the web server to pass the file to the PHP program for parsing and execution.
The PHP code is placed within an XML (or HTML) compliant tag and a semi-colon is used to end php instructions.
<?php
[php code code goes here];
?>
The command to get information on php server is:
<?
php phpinfo();
?>
This is saved as php_info.php, and then loaded through a browser. You will notice that the PHP expression as a string is <?php phpinfo(); ?> and that this .php file doesn’t contain any HTML at all! The .php extension tells the web server to pass the page through the php engine, and the result is passed to the browser. PHP shares some origins with Perl.
Recent Comments