1 / 7

Project 2

Project 2. Data Communication Spring 2010, ICE 3025-44 Stephen Kim, Ph.D. Due Date. April 9th, 2010. Mission. You will modify the previous project to make the server to handle multiple connections simultaneously. Echo Server

Télécharger la présentation

Project 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 2 Data Communication Spring 2010, ICE 3025-44 Stephen Kim, Ph.D.

  2. Due Date • April 9th, 2010

  3. Mission • You will modify the previous project to make the server to handle multiple connections simultaneously. • Echo Server • The server uses a thread library. On a successful connection, the accept() function returns a new socket. You create a new thread with a communication function, and the new socket and the client address are passed to the communication function that communicate with a client until it receive an empty message. • The child thread, or the communication function, receives a message from the client and print the client’s IP address and optionally the client’s port number followed by the message, repeatedly. For example, 115.145.203.30:4874 > Hello. World! • The parent thread waits for another connection with the accept() function.

  4. Echo Client • The previous client reads only one line from the keyboard. This short-lived execution is improper to demonstrate multiple connections at the server side. • You modifies the client to repeat the process of reading keyboard, sending, receiving, printing until a user enters an empty line. Be aware that the client sends the empty line to the server so that the server recognize the end of connection to close it properly. • The client shows the source of a message by using a keyboard prompt, and the server’s IP address and optionally the server’s port number followed by the message, repeatedly. For example, KEYBORD > Hello. World!142.35.203.30:3000 > Hello. World! • Empty message • Each message is terminated by a new line character, LF, CR, or CR/LF depending OS. • An empty message is a message containing no user message but the new line character.

  5. Team • You will form a group of 5 persons. • Each group submits ONE copy of the project report, but each member completes a “Peer Rating” form and submits it to the instructor CONFIDENTIALLY.

  6. Requirement • The project description must be properly demonstrated in the project report. • Use either C or C++ programming language. Period. • The submission must include soft and hard copy of • source files (C files and H files) • text trace of compilation • text trace of execution (the client side, and the server side) • All codes must be properly formatted and tabbed, and include proper in-line documents (comments). • All submission must be archived (compressed) into a single file for submission of soft copy.  

  7. Tips for POSIX Thread • Pthread tutorials and resources • http://en.wikipedia.org/wiki/POSIX_Threads • http://ko.wikipedia.org/wiki/POSIX_쓰레드 #include <pthread.h> #include <stdio.h> #include <stdlib.h> #define NUM 5 void *PrintHello(void *threadid) { long tid; tid = (long)threadid; printf(“Thread #%ld!\n", tid); pthread_exit(NULL); } int main (intargc, char *argv[]) { pthread_t threads[NUM]; intrc; long t; for(t=0; t<NUM; t++){ rc = pthread_create(&threads[t], NULL, PrintHello,(void *)t); if (rc) { fprintf(stderr, "ERROR;%d\n“,rc); exit(-1); } } pthread_exit(NULL); }

More Related