A simple chat client/server system have a simple graphical user interface with separate areas for messages received and message being typed. Each user have a nickname by which they will be identified in all received communications. The system allow users to join and leave the conversation at any time.
Multi-user chat systems allow users to participate in chart rooms where they can chat together. The status of users such as on-line, off-line and busy etc show on the program window. User type messages into the message input area and send it out by pressing the send button, the receiver capture the message and display it in message display area.
Chart room is a server side program and users run the chart client program in their own computers. All chart client need to connect the server chart room program to start the communication.
The server side code works for multiple users:
// While loop to accept() client requests :
// For each client connection request, accept() generates a new socket (sockfd).
// A child process is forked and use new_sockfd to communicate with client.
while(1) // parent process always loops to wait for new client connect.
{
sin_size = sizeof(struct sockaddr_in);
if ((new_sockfd = accept(sockfd, (struct sockaddr *)&clnt_info, &sin_size)) == -1)
{
perror("accept error");
continue;
}
pid=fork(); // fork a child process to service client connection
switch(pid)
{
case -1: // if occur fork errror
{
perror("fork error");
exit(1);
}
case 0: // this is the child process
{
close(sockfd); // close listener, child doesn't need the socket of listener
.................
The client side pass the socket information to server:
// Connet to remote server
if (connect(sockfd, (struct sockaddr *)&srv_info, sizeof(struct sockaddr)) == -1) {
perror("connect error");
exit(1);
}
//get client's information by getsockname() & stored in struct sockaddr clnt_info
getsockname(sockfd, (struct sockaddr*) &clnt_info, (int *) sizeof(clnt_info));
Different clients connect to the server by socket, so the server can distinct users by different socket connection.
// While loop to accept() client requests :
// For each client connection request, accept() generates a new socket (sockfd).
// A child process is forked and use new_sockfd to communicate with client.
while(1) // parent process always loops to wait for new client connect.
{
sin_size = sizeof(struct sockaddr_in);
if ((new_sockfd = accept(sockfd, (struct sockaddr *)&clnt_info, &sin_size)) == -1)
{
perror("accept error");
continue;
}
pid=fork(); // fork a child process to service client connection
switch(pid)
{
case -1: // if occur fork errror
{
perror("fork error");
exit(1);
}
case 0: // this is the child process
{
close(sockfd); // close listener, child doesn't need the socket of listener
.................
The client side pass the socket information to server:
// Connet to remote server
if (connect(sockfd, (struct sockaddr *)&srv_info, sizeof(struct sockaddr)) == -1) {
perror("connect error");
exit(1);
}
//get client's information by getsockname() & stored in struct sockaddr clnt_info
getsockname(sockfd, (struct sockaddr*) &clnt_info, (int *) sizeof(clnt_info));
Different clients connect to the server by socket, so the server can distinct users by different socket connection.
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?

Peer-to-Peer computing refers to a group of systems and applications that employ distributed resources to perform a function in a decentralized manner. The critical function can be distributed computing, data and content sharing, communication and collaboration, or platform services. Typical P2P systems place in the edge of Internet or in ad-hoc networks. P2P computing enables valuable externalities, lower cost of ownership and cost sharing, and anonymity/privacy.(Milojicic, 2003). P2P computer network does not have clients or servers but only equal peer nodes that simultaneously function as both 'client' and 'server'. P2P gained visibility with Napster's support for music sharing on Web (Napster, 2001).
Grid computing is an application used to run by several computers together to solve a problem at the same time, usually involve in a scientific or technical problem which requires a large number of computer processing power or access to a lot of data. Grid computing can also be thought as distributed and large-scale cluster computing (Wikipedia 2009).
3. Frameworks for development. Compare and contrast any TWO of:
a. Java
b. NET
c. Ruby on Rails
d. Turbo Gears
e. Google Gears
f. AJAX frameworks
Compare and contrast of Java and .Net (Thomsen, N.a.):


- Both are multi-tiered, similar computing technologies
- Both support 'standards'
- Both offer different tools and ways to achieve the same goal.
- A lot of parallelism
- As each has its own pro and con, it is difficult to compare and qualify the comparsion

- .Net can use VB, C# as it programing language
- C# and Java are an object oriented language
- The syntax of C++, C# and Java are similar

- JVM designed for platform independence
- CLR designed for language independence (Muliple languages for development)
- Java byte code (or JVML) is the low-level language of the JVM.
- MSIL (or CIL or IL) is the low-level language of the .Net Common Language Runtime (CLR)
Development tools:
- Well support in server-side for both Java and .Net IDEs
- .Net IDE's benefit from the fact that .Net CF is so close to .Net on the client-side (There are separate IDE's for desktop and mobile application development in Java)
- There has compatibility problems between Java vendors
- Java IDEs are slow
- C# is richer/more complex language than Java
- Both Java and .Net have well documented API
- Support for encryption of web services (.Net CF: https and SOAP extensions / J2ME: https, but only in CDC & MIDP 2.0
- Slow in start up when developing in Java
- Trouble-free implementation in .Net
- .Net integrates web service and mobile application developement far better than Java IDE
- A subset of an API is better solution for mobile devices instead of an entirely new API
- .Net is a better designed framework, because it eleiminates the language barrier while also being platform independent, and it makes only little distinction between desktop and mobile application development
- Sun's application server performance is very poor compared to IIS
- License fees for a Java based solution are cheaper but .Net might catch up when considering development time
Reference
- Milojicic, D. S. (2003), Peer-to-peer computing, HP Laboratories Palo Alto, HPL-2002-57 (R.1).
- Napster (2001), The Napster home page, http://www.napster.com/
- Thomsen, B. (n.a.) Java vs .net, Aalborg University, Department of Computer Science, Retreived from http://www.myplick.com/view/afZKCnJuG9C/Java-vs.-.Net on 12th Mar, 2009.
- Wikipedia (2009), Grid computing Retrieved from http://en.wikipedia.org/wiki/Grid_computing on 11th Mar, 2009.

No comments:
Post a Comment