answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tino4ka555
2 months ago
11

In this assignment, you are provided with almost-working code that establishes a TCP socket connection over the INET domain (tho

ugh for this assignment you should run and test your client-server code on the same machine). What is missing are the actual parameters for each of the four connection establishment socket APIs on the server and the two connection establishment socket APIs on the client (you will see a ? where the function parameters should be). Here are some identifying characteristics about the sockets you will be creating: • Use the INET domain for the socket type. • Use TCP sockets. • Use a backlog of 10 partially completed connections for the kernel to queue. Your goal for the first part of this assignment is to fill in the socket APIs with their needed parameters, but you should not add any new lines of code (until told to do so) as all of the needed supporting information such as variable declarations and initializations has already been provided. Use what is given to you, but do not change the intent of the program. If completed successfully, you will see the message "Server Message: SUCCESS" on the client side, but nothing on the server-side (although the server-side should still be running). The client-side only runs once while the server-side runs indefinitely, so you can run the client multiple times. To quit the server-side program, you may use CTRL-C (i.e., ^C). Go ahead and stop the server-side socket program now and then attempt to run the server-side socket program again. Does it work? Or does it give you an error? Knowing why you are getting this error is important! Normally, we would call unlink() to delete the socket "file", but this only works on UNIX domain sockets, not the INET sockets that we are using. For INET sockets, there is no file system token representing them, so we need to set a socket option to re-use the address as follows: int on = 1; setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); Now, enter the above two lines of code just before where the error is occurring. Then recompile and run your socket program again. Hopefully, you will no longer get these same errors as before. Make sure your client-server socket program works as expected and then submit both code files. 2 REQUIREMENTS: • No comments are required for this recitation assignment, except for your name at the top of the program. • Your program should have two components named "rec08svr.c" and "rec08cli.c", without the quotes, for the server and client code, respectively. • Your program will be graded based largely on whether it works correctly on the CSE machines (e.g., cse01, cse02, …, cse06), so you should make sure that your program compiles and runs on a CSE machine. • Although this assignment is to be submitted individually (i.e., each student will submit his/her own source code),
rec09svr.c

// compile: gcc rec09svr.c -o rec09svr

// usage : ./rec09svr port

#include

#include

#include

#include

#include

#include

#include

#include

#include

int main(int argc, char *argv[])

{

int listenfd = 0, connfd = 0, cli_size, portno;

struct sockaddr_in serv_addr, cli_addr;

char sendBuff[1025];

if ((listenfd = socket( ? )) == -1)

{

printf("socket error\n");

exit(EXIT_FAILURE);

}

memset(&serv_addr, '0', sizeof(serv_addr));

memset(sendBuff, '0', sizeof(sendBuff));

serv_addr.sin_family = AF_INET;

serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);

portno = atoi(argv[1]);

serv_addr.sin_port = htons(portno);

if (bind( ? ) == -1)

{

printf("bind error\n");

exit(EXIT_FAILURE);

}

if (listen( ? ) == -1)

{

printf("listen error\n");

exit(EXIT_FAILURE);

}

while (1)

{

cli_size = sizeof(cli_addr);

if ((connfd = accept( ? )) == -1)

{

printf("accept error\n");

exit(EXIT_FAILURE);

}

strcpy(sendBuff, "Server Message: SUCCESS\n");

write(connfd, sendBuff, strlen(sendBuff));

close(connfd);

sleep(1);

}

return 0;

}

the second one

rec09cli.c

// compile: gcc rec09cli.c -o rec09cli

// usage : ./rec09cli port

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

int main(int argc, char *argv[])

{

int sockfd = 0, n = 0, portno;

char recvBuff[1025];

struct sockaddr_in serv_addr;

memset(recvBuff, '0', sizeof(recvBuff));

if ((sockfd = socket( ? )) < 0)

{

printf("socket error\n");

exit(EXIT_FAILURE);

}

serv_addr.sin_family = AF_INET;

portno = atoi(argv[1]);

serv_addr.sin_port = htons(portno);

serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");

if (connect( ? ) < 0)

{

printf("connect error\n");

exit(EXIT_FAILURE);

}

while ((n = read(sockfd, recvBuff, sizeof(recvBuff)-1)) > 0)

{

recvBuff[n] = 0;

if (fputs(recvBuff, stdout) == EOF)

{

printf("fputs error\n");

}

}

if (n < 0)

{

printf("read error\n");

}

return 0;

}
Computers and Technology
1 answer:
zubka84 [1K]2 months ago
3 0
This text appears to have been copied and pasted.
You might be interested in
Which of the following is true of how the Internet has responded to the increasing number of devices now using the network? a) T
Harlamova29_29 [1022]

Answer:

A

Explanation:

Every year, internet protocols are adjusted to accommodate the influx of new devices on the network. In the 1990s, traffic primarily utilized a few protocols.  IPv4 managed packet routing, TCP handled those packets to establish connections, SSL (later TLS) secured those connections, DNS resolved hostnames, and HTTP was the main application layer protocol utilized.

For years, there were minimal modifications to the fundamental internet protocols; HTTP saw the addition of some new headers and methods, TLS underwent gradual updates, TCP improved congestion management, and DNS incorporated features like DNSSEC. Over a lengthy period, these protocols remained consistent as seen on the wire — with the exception of IPv6, which is regularly discussed among network operators.

Consequently, network administrators, vendors, and policymakers seeking to understand (and sometimes regulate) the Internet have implemented various practices based on the protocols’ wire ‘footprint’ — whether to troubleshoot issues, enhance service quality, or enforce policies.

Currently, there are considerable changes happening in core internet protocols. Although these updates aim to remain compatible with the wider Internet to ensure adoption, they might disrupt entities that have exploited undocumented features of existing protocols or assumed stability in certain aspects.

8 0
4 months ago
Read 2 more answers
Suppose you decide to use the number of times you see any of the area codes of the places Yanay has been to in 50 spam calls as
Harlamova29_29 [1022]
In Python: import random def simulate_visited_area_codes(): area_codes = [] for i in range(51): num = random.randint(200,1000) area_codes.append(num) visited_codes = [289, 657, 786, 540] count = 0 for i in range(51): for j in range(len(visited_codes)): if area_codes[i] == visited_codes[j]: count+=1 return count print("Visited Areas: " + str(simulate_visited_area_codes())) Explanation: Your question appears to lack many details, and therefore I will make some assumptions. These are: The 50 area codes are stored in the area_codes list, which is populated with randomly generated values. The visited area codes are saved in visited_codes list, initially set as [289, 657, 786, 540]. The subsequent program aims to count and explain the necessary steps.
8 0
2 months ago
A computer’s memory is composed of 8K words of 32 bits each. How many bits are required for memory addressing if the smallest ad
Natasha_Volkova [1026]

Answer:

The required number of bits to address 8K words is 13.

Explanation:

Addressable words total 8000, where a word is defined as the smallest unit of memory that can be addressed.

These 8000 words can be accessed using 2^{n} units. To find the value of n corresponding to the number of words, you need to calculate

2^2=4\\2^4=16\\2^7=128\\2^{10}=1024\\2^{12}=4096\\2^{13}=8192

It's clear that 13 bits are necessary to address 8K words.

7 0
4 months ago
Jane's organization recently experienced a security incident that occurred when malware set to trigger on the chief executive of
amid [951]

Answer:

The type of malware involved is a virus

Explanation:

This is because it is malicious software that burrows into another program and typically executes destructive tasks, like erasing data.

4 0
3 months ago
Other questions:
  • According to the author, there are five hedging strategies organizations can pursue. One of them is: Select one: a. commit with
    5·1 answer
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
    6·1 answer
  • Using the format method, fill in the gaps in the convert_distance function so that it returns the phrase "X miles equals Y km",
    12·1 answer
  • Write the pseudocode that determines the change to be dispensed from a vending machine. An item in the machine can cost between
    9·1 answer
  • When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
    11·2 answers
  • Write a local function named maxvalue that returns the maximum of two inputs numa and numb.
    10·1 answer
  • Which phrase best describes a scenario in Excel 2016?
    9·1 answer
  • The given SQL creates a Movie table with an auto-incrementing ID column. Write a single INSERT statement immediately after the C
    12·1 answer
  • Your computer has gradually slowed down. What's the most likely reason?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!