CS360
Internet Programming-
Welcome to CS360
Posted on March 25th, 2009 1 commentThis is going to be a busy, but hopefully exciting semester. During this course, we will develop a web server to help you understand what is going on under the covers when you write a web application. We will become familiar with low level operating system functionality that is necessary in any multithreaded networking application. We will also develop web applications with increasing degrees of sophistication. Our emphasis will be in giving you experience with real technologies that you will be using in the future in whatever career path you choose.
-
Comparing Web Technologies
Posted on June 4th, 2009 1 commentComparing Web Technologies
There are several things you should think about when selecting a technology for developing web applications:
- Performance – interpreted languages may seem slower, but since the database will be the bottleneck for many applications, the raw speed possible may be less important.
- Model View Controller Architecture – There are frameworks that will help you to use good design principles. It is worth it to use a system where it is difficult to write bad code.
- Library Availability – You dont want to write all of the code yourself
- Documentation – And more importantly, working examples are important
- Maturity – you dont want to pick something that is going to fade away as quickly as it appears, on the other hand, you shouldnt stick with bad technology just because it has been around for a while.
- Language Features – Object oriented, ORM database encapsulation
- Maintanence – Most of your effort will be spent here, so it should be easy to maintain and easy to have other people maintain.
- Culture – To some extend, the culture of the community is important. Are programmers willing to share, help each other? Is it an open source project?
Here are some comparisons of different technologies
-
MYSQL Hints
Posted on May 21st, 2009 No commentsMysql installation notes
- Copy the tar file from ~clement/mysql-5.0.24a.tar
- untar it into a directory in /tmp so you dont fill up your disk space.
- Configure and make
- Install the database
- Create the configuration file in mysqlbin/my.cnf, it should look something like the following. You should put the port number in that you will be starting the daemon on.
- You should put ~/mysqlbin/bin at the first of your search path
- Add MYSQL_HOME to your environment
- You can start the daemon by running:
- You can set the root passwd:
- You can create users:
- First start up mysql
mysql -u root -p
- Then create a cs360 user
create user cs360;
- Then grant permissions to this user
grant all on *.* to 'cs360'@'%.cs.byu.edu'; grant all on *.* to 'cs360'@'localhost'; flush privileges;
- Now you can connect through mysql using this new user
mysql -u cs360
- If you want PHP to work, you will also have to recompile php with mysql enabled
./configure --prefix=$HOME/php --with-apxs2=$HOME/apache2/bin/apxs --with-pdo-mysql=$HOME/mysqlbin
./configure --prefix=$HOME/mysqlbin --sysconfdir=$HOME/mysqlbin/mysqlconfig --localstatedir=$HOME/mysqlbin/mysqlstate --with-unix-socket-path=$HOME/mysqlbin/mysql/mysql.sock make make install
~/mysqlbin/bin/mysql_install_db --basedir=$HOME/mysqlbin --datadir=$HOME/mysqlbin/mysqldata --pid-file=$HOME/mysqlbin/mysqlpid --socket=$HOME/mysqlbin/mysql/mysql.sock
(my.cnf file contents follow)
[mysqld] datadir=/users/faculty/clement/mysqlbin/mysqldata socket=/users/faculty/clement/mysqlbin/mysql/mysql.sock skip-innodb [mysql.server] user=clement basedir=/users/faculty/clement/mysqlbin [safe_mysqld] err-log=/users/faculty/clement/mysqlbin/mysql.errlog pid-file=/users/faculty/clement/mysqlbin/mysqlpid port=1236 [client] socket=/users/faculty/clement/mysqlbin/mysql/mysql.sock port=1236
MYSQL_HOME=$HOME/mysqlbin
mysqld_safe --defaults-file=$HOME/mysqlbin/my.cnf
You can shut down the server using mysqladmin
mysqladmin -u root -p shutdown
If you have trouble with it complaining about permissions to the log file, try substituting your username into the following:
bin/mysqld_safe --basedir=$HOME/mysqlbin --datadir=$HOME/mysqlbin/mysqldata --pid-file=$HOME/mysqlbin/mysqlpid --socket=$HOME/mysqlbin/mysql/mysql.sock --port=1236 --log-error=$HOME/mysqlbin/mysql.errlog
mysqladmin -u root password yourpasswd
Midterm Exam Review
The midterm exam will be in the testing center from October 23-27. You may bring one hand written page of notes of your own making to the exam.
The following questions should provide a good review for the exam:
- Describe perl regular expressions and hashes.
- What will the following code print out?
my %ancestors = ( grandfather => "gp", gm => "grandmother", great => "ggf", ); my @mkey = keys %ancestors; my @mval = values %ancestors; print "key ", @mkey[1], ", value ", @mval[2], "\n"; print "gm = ", $ancestors{"gm"}, "\n"; - What is the value of the variable $var after the following code fragment is executed?
$var = "This Midterm"; $var =~ s/^([^ ]*) *([^ ]*)/$2 $1/;
- What does the listen() command do and how is it related to the connection oriented nature of TCP?
- Is IP connection oriented?
- Is Ethernet connection oriented?
- Is TCP connection oriented?
- Is HTTP connection oriented?
- What are the 7 layers in the OSI model?
- What does the bind() procedure in the socket library do? How does it interact with the TCP and IP layers of the protocol stack.
- What is the port used in binding to a socket?
- What is a socket? How does a web server use sockets to distinguish between different clients that connect to it?
- What are the steps a web server must take in processing an HTTP request?
- What are the differences between the way a web server deals with a GET or POST cgi request.
- Is HTTP a stateless protocol?
- What are the 3 ways for a web application to maintain session state?
- Compare the pros and cons of each method of maintaining state?
- Explain how an HTTP cookie works. How does a perl application use cookies to create persistant state.
- What are the advantages and disadvantages of CGI?
- What does the SECURE keyword indicate for a cookie?
- What is the size limitation on cookies?
- What may a Unix file descriptor represent?
- When a web server executes a fork() command, both the parent and the child will have a file descriptor associated with the socket that is connected to the web browser. When the child executes a CGI script and that script exits, what will happen to the socket connected to the browser?
- What does the execve system call do?
- How do signals work with threads and processes?
- What does the integer value in a semaphore represent?
- What is a race condition?
- Compare and contrast user level and kernel level threads.
- What are the differences between threads and processes?
- What does the fork() system call return?
- What system call would you use to determine file information?
- What system call would you use to change the stdout of a process?
- Why would you want to use a thread pool instead of a single thread for serving requests from browsers?
- Why would you want to use a thread pool instead of spawning a new thread for each request from a browser?
- How does a proxy work and how does a web browser maintain a cache?


