Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
CSCI3240 Lab5:
Network Programming -Client
1 Overview
In today’s lab, we will be learning to use sockets for interprocess communication.
1.1 The Client Server Model
Most interprocess communication uses the client-server model. These terms refer to the two processes which will be communicating with each other. One of the two processes, the client, connects to the other process, the server, typically to make a request for information. A good analogy is a person who makes a phone call to another person. Notice that the client needs to know of the existence of and the address of the server, but the server does not need to know the address of (or even the existence of) the client prior to the connection being established.
Notice also that once a connection is established, both sides can send and receive infor- mation. The system calls for establishing a connection are somewhat different for the client and the server, but both involve the basic construct of a socket. A socket is oneend of an interprocess communication channel. The two processes each establish their ownsocket.
Basically, the steps involved in establishing a socket on the client side are as follows:
1. Create a socket with the socket() system call
2. Connect the socket to the address of the server using the connect() system call
3. Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.2
Objective:
• Understand the role of a client in the Client-Server (CS) architecture.
• Learn how to create a TCP client using the C programming language.
• Gain hands-on experience with socket programming for network communications.
Client Functionality Description:
• The client connects to a TCP server at a specified address and port.
• It prompts the user to enter a message, which it then sends to the server.
• The client waits for and displays the server's response.
• The client prompts the user again for a second message, sends it, and displays the server's second response.
• The client then closes the connection.
Server Address and Port Specification:
The server's address and port number are input via command-line arguments.
For example, running ./client 127.0.0.1 12345 will make the client connect to a server at Localhost (127.0.0.1) on port 12345.3
2 Output of Sample Code
Here is an example of a run of the above program. We use a makefile to compile client and server programs. Link to a simple makefile tutorial: Makefile Tutorial.
3 Submission Instructions
1. It should include:
(a) client.c
(b) server.c
(c) makefile
2. Submission Due: Check Lab5 Dropbox
4 Grading Rubrics
1. Client/Serve compilation error: -40
2. Segmentation faults after correct execution: -20
3. If server terminates (Server should never terminate): -10
4. Client did not terminate: -10
5. Required files missing (other than client.c and server.c): -20