Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
11/ 01/ 2013 TELE 3118 -  M ini- pr oject
1/ 2f ile: / / / C: / Docum ent s and Set t ings/ Taha/ Deskt op/ code/ m inipr oject . ht m l
TELE 3118: Network Technologies: Mini-project [10 points]
A TCP server of the type that you will implement in part 2 is running on IPaddr=149.171.37.252, tcp-
port=31180. You can use it to test your TCP client
Note: This assignment can be done in pairs (i.e. groups of two people); but if so, you are required to inform the
lab demonstrators about the pairing by email no later than the end of week 9. Partners for the mini-project need
not be from the same lab session. The working code is to be demonstrated in lab during weeks 12 and 13.
This lab introduces you to network programming using the socket API. The application you will develop is a
simple version of a chat program that allows two users to chat to each other. More sophisticated chat programs
like Yahoo messenger and MSN chat allow many more users, multi-party communication, etc, which can be
seen as refinements to this project. Your application will consist of two parts:
Part 1 [5 points]:Chat registration client: This part requires you to write a program that sends a registration
message to the registration server. The registration server code is provided to you, and the server is currently
running on 149.171.37.252 on UDP port number 31180. Your registration message to the server has to have
the following format:
The password (should fit in an array of 16 bytes), currently set to the string "3118miniproject".
Your user-name (should fit in an array of 14 bytes), which is a string of characters of your choice.
The TCP port number on which your chat program (of part 2 below) sends and receives chat messages.
This is sent as a 2-byte number (unsigned short) in network format.
Your registration message should be constructed as per the format above (please see the "RegMsg_t" structure
in the file "chatRegServ.c" for the precise format in C), and should be sent periodically (once per minute) to the
registration server, otherwise the server will consider you (the user) as having logged off or crashed. In response
to your registration message, the server will send you back a message with a list of all logged-in users, in the
format below (available as the "RegRespMsg_t" structure in the file "chatRegServ.c"):
The first 4-bytes (unsigned integer, in network order) will indicate how many users are logged-in.
The rest of the mesage will be an array (of at most 50 items) of a structure that includes the following
information for each logged-in user: 14-byte user-name, followed by 2-bytes of TCP port-number (in
network format), followed by the 4-byte IP address.
Part 2 [5 points]:Chat message server/client: Once your code from part 1 above registers with the server and
obtains the IP address/port of other logged-in users, this part will now require you to establish a TCP session
with another user to exchange chat messages. Your code will implement a TCP client that connects to the server
(corresponding to the IP address and port number of the user you want to chat with), and exchanges a specified
number of chat messages with the other user. Specifically your client will have to read messages typed (on the
keyboard) by you and send them to the server, and also receive messages from the server (over the network)
user and display them on the screen (much like a typical chat session). Points will be awarded based on how well
the code and interface are structured.
Implementation notes:
You are recommended to use C as the programming language (Java may be used but will not be
11/ 01/ 2013 TELE 3118 -  M ini- pr oject
2/ 2f ile: / / / C: / Docum ent s and Set t ings/ Taha/ Deskt op/ code/ m inipr oject . ht m l
supported by the lab instructors). During compilation of your C programs, you may need to link with
socket libraries using the "-lnsl" option in gcc.
The TCP message itself consists of nothing other than the string typed by the user.
There are numerous tutorials and sample programs on the Internet that illustrate the use of sockets. A
sample primer is available here. Useful templates for your implementation may be obtained here
(companion to the book "The Pocket Guide to TCP/IP Sockets - C Version" by M. Donahoo and K.
Calvert).
Use "man" and "info" to learn more about the socket functions used.