r code where: i) A socket is created. ii) The properties of the created socket are filled in. Use the last 4 digits of your student ID (9 digit ID) as port number. iii) The created socket is associated with its properties using the appropriate system call and parameters. iv)Take the last digit of your student ID (9 digit ID); if it is an odd number you are going to write the code for a TCP server from the listening socket and

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

This question relates to Socket Programming in C. From the code shown in Figure 4
write the part of the server code where:
i) A socket is created.
ii) The properties of the created socket are filled in. Use the last 4 digits of your
student ID (9 digit ID) as port number.
iii) The created socket is associated with its properties using the appropriate system call
and parameters.
iv)Take the last digit of your student ID (9 digit ID); if it is an odd number you are going to write
the code for a TCP server from the listening socket and all the steps of code after iii)
to allow the server to communicate with one client by receiving a request from the
client and sending the answer “I got your request!”. If the last digit of your student
ID (9 digit ID, 123456789) is an even number, you are going to write all the steps of code from iii) for a UDP
server to communicate with one client by receiving a request from the client and
sending the answer “I got your request!”.
Notes:
1. Inside the code you must add meaningful explanatory comments to major
commands and semantics of what the control structures are performing in relation
to the realisation of the code. Comments must be short, clear, and objective about
how the code will perform.
2. The code you write for parts i) to iv) above must use the variables declared in
Figure 4. Code dump will not be accepted as an answer.
3. In Figure 4, some parts of the code are omitted due to space limitation, but all the
necessary code for answering the question is shown in the figure.

1 /*
Simple Server in C. */
2 /* Headers needed for the program. */
3 // ...
4
void error (char *msg) {
fprintf(stderr,
exit (1);
LSSA WNT
5
6
7
8
9
10
11
12
13
14
15
16
17
18
}
"%s:%s\n", msg, strerror(errno));
int main(int argc, char *argv[]) {
// Variable declarations
int sock_server, com_sock;
int portno, n;
socklen_t cLen;
char buffer [256];
struct sockaddr_in serv_props, clt_props;
/* Your code follows */
//
Transcribed Image Text:1 /* Simple Server in C. */ 2 /* Headers needed for the program. */ 3 // ... 4 void error (char *msg) { fprintf(stderr, exit (1); LSSA WNT 5 6 7 8 9 10 11 12 13 14 15 16 17 18 } "%s:%s\n", msg, strerror(errno)); int main(int argc, char *argv[]) { // Variable declarations int sock_server, com_sock; int portno, n; socklen_t cLen; char buffer [256]; struct sockaddr_in serv_props, clt_props; /* Your code follows */ //
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY