Professional Documents
Culture Documents
Lab Quiz
Lab Quiz
Reg.no : 22BRS1303
Name : Nisha Dipak gote
Course Code : BCSE308P
Course Title : COMPUTER NETWORKS
LAB Slot : L5+L6
Faculty Name : DR.A.SWAMINATHAN
QUESTION: Using the given components and devices, such as routers, switches and cat6 cables,
create a of any topology. Configure the router and configure the IP for all n nodes connected in the
network using dynamic DHCP. Write a UDP Client Server program to perform a
multiuser chat program.
SERVER CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
int main() {
int sockfd;
socklen_t client_len;
char buffer[BUFFER_SIZE];
if (sockfd < 0) {
exit(EXIT_FAILURE);
}
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
server_addr.sin_port = htons(PORT);
perror("Bind failed");
exit(EXIT_FAILURE);
while (1) {
memset(buffer, 0, BUFFER_SIZE);
if (recv_len < 0) {
exit(EXIT_FAILURE);
close(sockfd);
return 0;
CLIENT CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
int sockfd;
char buffer[BUFFER_SIZE];
if (sockfd < 0) {
exit(EXIT_FAILURE);
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(PORT);
while (1) {
exit(EXIT_FAILURE);
close(sockfd);
return 0;
}
OUTPUT:
: