1answer.
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
Rus_ich [418]
3 years ago
12

A haiku is a three-line poem in which the first line contains five syllables, the second line contains seven syllables, and the

third line contains five syllables. Write a haiku server that listens to port 5755. When a client connects to this port the server responds with a haiku; written in C language. Should only be a few lines of code.
Computers and Technology
1 answer:
tankabanditka [31]3 years ago
4 0

Answer:

Files :

server.c

client.c

Haiku msg : ( source internet )

Birds fly through the wind

The wind blows through the blue sky

Winds of change grow close

Explanation:

server.c

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <sys/socket.h>

#include <netinet/in.h>

// Here we've defined the PORT

#define PORT 5755

// This a out haiku_msg

const char haiku_msg[] = "Birds fly through the wind\nThe wind blows through the blue sky\nWinds of change grow close";

int main()

{

int server_fd, new_socket;

struct sockaddr_in address;

int addrlen = sizeof(address);

// Creating socket file descriptor

if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) {

perror("socket failed");

exit(EXIT_FAILURE);

}

address.sin_family = AF_INET;

address.sin_addr.s_addr = INADDR_ANY;

address.sin_port = htons(PORT);

if (bind(server_fd, (struct sockaddr*)&address, sizeof(address)) < 0) {

perror("bind failed");

exit(EXIT_FAILURE);

}

printf("haiku server started...\n\n");

if (listen(server_fd, 5) < 0) {

perror("listen");

exit(EXIT_FAILURE);

}

if ((new_socket = accept(server_fd, (struct sockaddr*)&address, (socklen_t*)&addrlen)) < 0) {

perror("accept");

exit(EXIT_FAILURE);

}

printf("\nClient connected to haiku server.\nsending msg.\n");

send(new_socket, haiku_msg, strlen(haiku_msg), 0);

printf("haiku sent to client.\n\n");

return 0;

}

client.c

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>

#include <arpa/inet.h>

#include <sys/socket.h>

#include <netinet/in.h>

// Here we have defined the PORT

#define PORT 5755

int main()

{

char buffer[1024] = "";

struct sockaddr_in address;

struct sockaddr_in serv_addr;

int sock = 0;

if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)

{

printf("\n Socket creation error \n");

return -1;

}

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

serv_addr.sin_family = AF_INET;

serv_addr.sin_port = htons(PORT);

// Convert IPv4 and IPv6 addresses from text to binary form

if(inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)<=0)

{

printf("\nInvalid address/ Address not supported \n");

return -1;

}

if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)

{

printf("\nConnection Failed \n");

return -1;

}

read( sock , buffer, 1024);

printf("\nMessage from server : \n%s\n\n",buffer );

return 0;

}

You might be interested in
A key principle of human-computer interaction (HCI), that states that the appearance of any control should suggest its functiona
kaheart [24]

Answer:

"Affordance" is the correct answer.

Explanation:

  • The performance or properties of such an entity that determines its possible applications which makes it abundantly clear how everything could and should always be used people are sitting or standing on something like a chair as it is very apparent.
  • Users are allowed to experience conceptions without thinking about how to make use of other objects.
4 0
3 years ago
Which two characters do you use to tell the command that you are finished providing options and that the remaining data on the c
sergiy2304 [10]

Answer:

Two hyphen-minus characters (- -)

Explanation:

Using two hyphen-minus characters only, tend to recommend that the rest of the data are arguments and should not be treated as alternatives.

Hence, in this situation, the two characters a user will use to tell the command that a user is complete giving options and that the rest of the data on the command line is arguments is known as "two hyphen-minus characters (- -)"

8 0
3 years ago
Critical Thinking Questions
Pani-rosa [81]

Answer:

Explanation:

1) Assassins Creed Valhalla. The developers (ubisoft?) is canadian i think. The culture of ACV is of the vikings. Some advantages would be many people could learn about viking culture but some concerns is since it may not be the developers culture some information could be wrong and many people could be misinformed

2) personally i would put them in the order of Asteroid, Pac Man, then modern warfare.

this is all i really know sorry

but i hope this helps <3

8 0
3 years ago
Read 2 more answers
Your class requires you to use a program you must download on your computer. You have waited until day 5 of the week to download
Nimfa-mama [501]

In the above scenario, The way to solve the problem is to would contact tech support.

<h3>Whom would you contact first, and why?</h3>

I would also contact the number that is saved on my student ID for help as they will known about such problems.

The resources available to still read my detailed notes that I wrote, that tells  the step by step way to quick fix it or contact the instructor to let them know of the current situation.

Therefore, In the above scenario, The way to solve the problem is to would contact tech support.

Learn more about program from

brainly.com/question/1538272

#SPJ1

5 0
2 years ago
Define the following terms, as they pertain to website planning: goals, objectives, target audience, and purpose statement. Expl
zepelin [54]

Answer:

Please see explanations below

Explanation:

Goals; These are the outcomes that a website planning intends to achieve within a stipulated time, i.e weeks, months or years.

Objectives; These are the methods taken, through which the website planning goals will be achieved.

Target audience; These are the specific group of people that are intended to be reached for the website planning. The targeted audience could be identified based on age range, academic background or qualification, gender or marital status.

Purpose statement; This refers to an explanation of the website's planning goals, which is formally written and also shows the main objectives identified with the goals.

The Influence on society of inexpensive internet access and access to the web are numerous; yet it provide information that are not readily accessible by individuals before using the internet. For information to be accessed through internet access by all and sundry, it must come at little or no cost, which is what is currently obtainable in most part of the world.

Moreover, inexpensive access to the internet and web also improve quality of knowledge in addition to the existing ones through research, which is mostly done through the internet.

However, there are also downside of inexpensive access to the internet and web which now depends on whichever individuals want. For instance not every information on the website are true or correct. The right thing to be done is to further search and compare several ones until the right one is found.

5 0
4 years ago
Other questions:
  • The ASE certification system uses _______ testing and an evaluation of on-the-job experience to confirm that a technician meets
    15·2 answers
  • Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in t
    12·1 answer
  • What are the two ways that assets are
    5·1 answer
  • Dawn needs to insert a macro into a Word document. Where can she find the Insert Macro dialog box?
    11·1 answer
  • 2. ¿Cuáles de los siguientes Software son lenguajes de Programación?
    10·1 answer
  • A predecessor of a work processor is​
    8·1 answer
  • Write a Coral program using integers userNum and x as input, and output userNum divided by x four times.
    7·1 answer
  • When you are typing data that is in a series, such as days of the week or months of the year, you can use this tool to complete
    11·1 answer
  • Pedestrians have ______.
    8·1 answer
  • Write a program that first reads a list of 5 integers from input. Then, read another value from the input, and output all intege
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!