Tuesday, March 24, 2009

Exercise 5: Network and programming frameworks

1. Investigate a simple chat client/server system. Look at some program code and describe how it works with multiple users.

Source code of Chat Client Server by Boby, T. P., (2006)

Server Side Main program:

**********************************************************************************
int main(int argc, char* argv[])
{
int nRetCode = 0;
char buf[4096];

cout << "This is written by Boby Thomas.\r\n";
cout << "This aplication act as a chat server.\n";
cout << "Messages from any pc will be broadcasted to all connected pcs.\n";
cout << "Connect to the server pc port 8084(Digital BOBY).\n";
cout << "Press ONLY ENTER to quit.\n";
cout << "=================================================\n";

if(!CServerObj.IsConnected())
{
cout<<"\nFailed to initialise server socket";
cout<<"\nThis is boby signing off : Bye";
getch();
return 1;
}
AfxBeginThread(ServerListenThread,0);

while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(CServerObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server. Check whether server is running\n";
break;
}
}

cout<<"This is Boby signing off.";
getch();

return nRetCode;
}
**********************************************************************************


Client Side Main program:

**********************************************************************************
int main(int argc, char* argv[])
{
char buf[4096];
cout<<"This is a client TCP/IP application\nConnecting to port 8084\n";
cout<<"\nPress ONLY ENTER to quit";
cout<<"\nWritten by Boby Thomas";
cout<<"\n===============================================\n";

FILE *fp = fopen("server.ini","r");
if(fp == NULL)
{
cout<<"\nUnable to open server.ini. Please specify server IPsddress in server.ini";
return 1; // main failed
}
string sServerAddress;
while((fgets(buf,4096,fp)) != NULL)
{
if(buf[0] == '#')
continue;
sServerAddress = buf;

}
fclose(fp);

if(sServerAddress.size() == 0)
{
cout<<"\nUnable to find server IPaddress in server.ini";
cout<<"\nPlease set server IPaddress";
cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}

MyMessObj.Init(sServerAddress.c_str(),8084);
if(!MyMessObj.IsConnected())
{
cout<<"\nUnable to connect to the IPaddress specified in server.ini";
cout<<"\nPlease check server IPaddress";
cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}

AfxBeginThread(MessageRecThread,0);
while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(MyMessObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server. Check whether server is running\n";
break;
}
}

cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}
**********************************************************************************


The chat program uses thread to serve multiple users. The server starts and listen to the network for client. The client side locates the server and starts chat. While each client connected to the server, a new thread creates in the server side for that client. As multiple threads created in the server side, multiple users can be served.

2. Describe the important and distinguishing properties of Peer to Peer computing and the Grid. How is this peer to peer and the Grid architecture changing work flow and service-oriented applications?

There are two common use of Grid computing. Both uses several computer to solve a problem. One of the usage is that the problem is complex and require a lot of computer cycle to complete such as a scientific problem.

The other usage is to handle a large amount of data. When a single server cannot handle all the requests, by using the grid computing, the servers are linked up to form a cluster, the transaction are distributed to the server members and is handled in parallel manner. (Wikipedia)

This is important for service-oriented applications. In e-commerce, all the transactions are handled in server. The server's power for handling the transaction become important. Instead of the security concern, the user or customer requires fast and efficient service via e-commerce. The slow transaction time leads the wait of customers or users, there will be a bad impact to the company goodwill and customer satisfaction.

Peer to Peer computing (P2P) links the computers in a ad hoc manner to increase the total bandwidth for sharing common interests such as audio, video and data files.

There are two roles for each computer that is linked up in Peer to Peer computing - server and client. It is a full duplex (two ways) communications to all computers that linked up. When a computer a linked to the P2P network, for example, download a Linux distribution, the computer downloads portions of the file from all the computers that it connected to, at the same time, the downloaded portions is uploaded to someone else who is connected and requiring that portion of file. (Wikipedia)

This is useful when a company cannot provide enough bandwidth for distribute their files. For example: RedHat and Novell SUSE, their files are in DVD format, if it provides only FTP service for download the file, there are not enough bandwidth to serve all the customers and users. By using the P2P techniques, the file can be distribute faster than the FTP to the customers and users.


3. Frameworks for development. Compare and contrast any TWO of:
a. Java
b. .NET
c. Ruby on Rails
d. Google Gears
f. AJAX frameworks

I would like to discuss on the frameworks for Java and Ruby on Rails.

The Ruby on Rails (RoR) providing Model-View-Controller approach as its development framework. It is the unique framework for the development platform. JAVA can adopt itself to different kind of the development frameworks. Some of the frameworks for Java are MVC framework.

While some of the development framework supporting Pull and Push architecture, the RoR only support Push technology. There is a weak point to the Java, most of the framework for Java is not able migrate with the database, but RoR does.

Most of the framework for Java supports AJAX while RoR does not support or still in prototype.


Table 1. Comparison of web application frameworks on Java and Ruby on Rails (Wikipedia)


Table 2. Comparison of web application frameworks components on Java and Ruby on Rails (Wikipedia)

Reference:
Boby, T. P., (2006), Chat Client Server, Retrieved 24 March 2009, from http://www.codeproject.com/KB/cpp/chat_client_server.aspx

GridCafe, (n.d.), How does grid computing work?, Retrieved 25 March 2009, from http://www.gridcafe.org/version1/gridatwork/architecture.html

Joseph, J., Ernest, M., Fellenstein, C. (2004) ,Evolution of grid computing architecture and grid adoption models, Retrieved 25 March 2009, from http://www.research.ibm.com/journal/sj/434/joseph.html

Wikipedia (n.d.), Peer-to-peer, Retrieved 25 March 2009, from http://en.wikipedia.org/wiki/Peer-to-peer

Wikipedia (n.d.), Grid computing, Retrieved 25 March 2009, from http://en.wikipedia.org/wiki/Grid_computing_infrastructure

Wikipedia (n.d.), Comparison of web application frameworks, Retrieved 30 March 2009, from http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

No comments:

Post a Comment