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
Effectus [21]
2 years 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:
Scrat [10]2 years ago
3 0
Holy copy and paste that was used here
You might be interested in
Write a program that defines a type for a structure that stores information on a student in ENG EK 125. Declare two variables to
Mashcka [7]

Answer:

Following are the program in the C Programming Language.

#include<stdio.h> //header file

#include<string.h> //header file

struct student//creating structure

{

 //set integer variables

int marks;

int roll;

};

//define function

void initial(struct student *stu)

{

 //set integer type variables

int marks=420;

int roll_no=45,i;

stu->marks=marks;//assigning the values

stu->roll=roll_no;//assigning the values

}

//define main method to call the function

int main()

{

struct student stu;

initial(&stu);//calling the function

printf("Total marks : %d\n",stu.marks); //print output

printf("Roll No. : %d\n",stu.roll); //print output

return 0;

}

<u>Output:</u>

Total marks : 420

Roll No. : 45

Explanation:

Here, we define the structure "student" with a struct keyword for creating a structure.

  • inside the structure, we set two integer type variable "marks", "roll".

Then, we define a function "initial()" and pass an argument in the parameter of the function.

  • inside the function, we set two integer type variable "marks", "roll_no" and assign the value in the variable "marks" to 420 and variable "roll_no" to 45.
  • Assign the value in the structure's integer variables from the function's variable.

Finally, we set the main method inside it we call the function "initial()" and pass the value and then, we print the output with message.

8 0
2 years ago
Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
inysia [295]

Answer:

Option (c) is the correct answer of this question.

Explanation:

RAM (Random Access Memory) It is a type of computer memory which can also be retrieved and adjusted in either sequence, usually still had to preserve operating memory and bytecode.

It is a type storage device, and maintains the data used when the device is operating.RAM makes file access more frequently compared with certain digital storage types.

 <u>For Example</u>:- PCs, tablets, smartphones ,printers etc.

Other options  are not related to the given scenario.

8 0
2 years ago
In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters traveled. Write a func
devlian [24]

Answer:

// here is code in java.

import java.util.*;

// class definition

class Main

{

// method that return total fare

   public static double fare(double dis)

   {

   // calculate the total fare

       double tot_fare=(4+((dis*1000)/140)*0.25);

       return the fare

       return tot_fare;

   

   }

   //driver method

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read input string

       Scanner s=new Scanner(System.in);

        // variable

       double dis;

       System.out.print("please enter the distance in KM: ");

       //read the number

       dis=s.nextDouble();

       

       // call the function with "dis" parameter

     double ride_fare=fare(dis);

     // print the total fare

     System.out.println("total fare is: "+ride_fare);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read the distance from user with the help of scanner class.Call the function with parameter "dis".Here it will calculate the total fare as (4+((dis*1000)/140)*0.25). Here base fare is $4 and $0.25 for every 140 meter.Then function will return the total fare.

Output:

please enter the distance in KM: 7                                                                                                                            

total fare is: 16.5  

7 0
2 years ago
Generating a signature with RSA alone on a long message would be too slow (presumably using cipher block chaining). Suppose we c
boyakko [2]

Answer:

Following are the algorithm to this question:

Explanation:

In the RSA algorithm can be defined as follows:  

In this algorithm, we select two separate prime numbers that are the "P and Q", To protection purposes, both p and q combines are supposed to become dynamically chosen but must be similar in scale but 'unique in length' so render it easier to influence. Its value can be found by the main analysis effectively.  

Computing N = PQ.  

In this, N can be used for key pair, that is public and private together as the unit and the Length was its key length, normally is spoken bits. Measure,

\lambda (N) = \ lcm( \lambda  (P), \lambda (Q)) = \ lcm(P- 1, Q - 1)  where \lambda is the total function of Carmichaels. It is a privately held value. Selecting the integer E to be relatively prime from 1and gcd(E,  \lambda (N) ) = 1; that is E \ \ and  \ \ \lambda (N).  D was its complex number equivalent to E (modulo \lambda (N) ); that is d was its design multiplicative equivalent of E-1.  

It's more evident as a fix for d provided of DE ≡ 1 (modulo \lambda (N) ).E with an automatic warning latitude or little mass of bigging contribute most frequently to 216 + 1 = 65,537 more qualified encrypted data.

In some situations it's was shown that far lower E values (such as 3) are less stable.  

E is eligible as a supporter of the public key.  

D is retained as the personal supporter of its key.  

Its digital signature was its module N and the assistance for the community (or authentication). Its secret key includes that modulus N and coded (or decoding) sponsor D, that must be kept private. P, Q, and \lambda (N) will also be confined as they can be used in measuring D. The Euler totient operates \varphi (N) = (P-1)(Q - 1) however, could even, as mentioned throughout the initial RSA paper, have been used to compute the private exponent D rather than λ(N).

It applies because \varphi (N), which can always be split into  \lambda (N), and thus any D satisfying DE ≡ 1, it can also satisfy (mod  \lambda (N)). It works because \varphi (N), will always be divided by \varphi (N),. That d issue, in this case, measurement provides a result which is larger than necessary (i.e. D >   \lambda (N) ) for time - to - time). Many RSA frameworks assume notation are generated either by methodology, however, some concepts like fips, 186-4, may demand that D<   \lambda (N). if they use a private follower D, rather than by streamlined decoding method mostly based on a china rest theorem. Every sensitive "over-sized" exponential which does not cooperate may always be reduced to a shorter corresponding exponential by modulo  \lambda (N).

As there are common threads (P− 1) and (Q – 1) which are present throughout the N-1 = PQ-1 = (P -1)(Q - 1)+ (P-1) + (Q- 1)), it's also possible, if there are any, for all the common factors (P -1) \ \ \ and \ \ (Q - 1)to become very small, if necessary.  

Indication: Its original writers of RSA articles conduct their main age range by choosing E as a modular D-reverse (module \varphi (N)) multiplying. Because a low value (e.g. 65,537) is beneficial for E to improve the testing purpose, existing RSA implementation, such as PKCS#1, rather use E and compute D.

8 0
2 years ago
Hybrid processors that can process 32 bits or 64 bits are known by what term?
patriot [66]
For the answer to the question above asking, what h<span>ybrid processors that can process 32 bits or 64 bits are known by what term?

I think you are referring to the Chipset. and they are Manufactured by Intel and Advance Micro Devices (AMD). Intel's Pentium is the first one to have 32 bits and 64 bits of processors.</span>
4 0
2 years ago
Other questions:
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • An automobile battery, when connected to a car radio, provides 12.5 V to the radio. When connected to a set of headlights, it pr
    11·1 answer
  • there are four stage of the product life cycle. during which of these stages do you think is the best time for a company to purc
    10·2 answers
  • Ming is building an inexpensive computer to use for her online classes, and needs to purchase Windows. What is the most cost-eff
    8·1 answer
  • Robert needs to apply formatting from one set of text to multiple other sets of text throughout the document. Which option shoul
    7·1 answer
  • Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation
    6·1 answer
  • 2 Name the package that contains scanner class?​
    10·1 answer
  • The fact that the speed of a vehicle is lower than the prescribed limits shall relieve the driver from the duty to decrease spee
    11·2 answers
  • The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
    5·1 answer
  • Cardinality ratios often dictate the detailed design of a database. The cardinality ratio depends on the real-world meaning of t
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!