Giter Club home page Giter Club logo

Comments (1)

hewei-nju avatar hewei-nju commented on July 17, 2024

This was the first project I studied, probably because of my limited ability, and I found that some places were not well understood. The following three points are some of my questions. Thank you for your guidance.

(1) Why isn't pid < 3 here? Is there any special meaning for pid being 2?

WebBench/webbench.c

Lines 411 to 416 in b1acf3c

pid=fscanf(f,"%d %d %d",&i,&j,&k);
if(pid<2)
{
fprintf(stderr,"Some of our childrens died.\n");
break;
}

(2) Why does the bench() function return i? Isn't this the speed value that the parent process successfully read the last time? Could I change the program to return 0?

return i;

(3) Add close(sock); is it more rigorous?

WebBench/socket.c

Lines 54 to 55 in b1acf3c

if (connect(sock, (struct sockaddr *)&ad, sizeof(ad)) < 0)
return -1;

My personal opinion:
(1): Because in common Linux operating systems, the PID of 0 and 1 have been occupied by the process operating system and the software which cooperates with the operating system.

(2): Currently, I'm facing the same problem with you, and I think you are true.

(3): Use man 3 connect, and I have found this sentenceAPPLICATION USAGE: If connect() fails, the state of the socket is unspecified. Conforming applications should close the file descriptor and create a new socket before attempting to reconnect. So I agree with you.

from webbench.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.