#does anyone know how servers work?

1 messages ยท Page 1 of 1 (latest)

mint fractalBOT
#

<@&987246964494204979> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
When you host a server, say on port 8000 and it listens for requests on that port, what physically happens? what does your computer do to actually host it?

When you host a server on a specific port, your computer essentially opens up that port for communication and listens for incoming requests. When a request is made to that port, the server program running on your computer processes the request and sends back a response. Your computer's network interface card (NIC) is responsible for transmitting and receiving data packets to and from the server.

Useful links:

pallid osprey
#

Have you learned about the network?

brazen mist
#

nah

pallid osprey
#

And ports?

brazen mist
#

nahh

light tapir
#

traffic first and foremost is handled by ur router

#

so eventually someone will send data to ur router (via IP address, using UDP or TCP as communication protocol)

brazen mist
#

i just wanna know what happens when i do npm run dev

light tapir
#

ur router then sends the data to ur computer bc uve "opened the port" on the router

#

like, u went into ur router settings and did what's called port forwarding

#

telling ur router "incoming traffic on port x, please send that to computer y"

#

so it forwards it

#

ur computer now receives the traffic

#

and that's happening through an API provided by ur OS

#

called the socket API

#

the socket API implements the tcp and udp communication protocol

#

thats ur entry point into communication with other machines

brazen mist
#

is there a good yt vid i can watch on this topic?

pallid osprey
#

The best analogy I've heard is the post with letters sent to people.
When you start a server, you tell a process to wait at the door (a port out of 0-65535).
That process will then wait for anyone to send a letter (a request).
When one happen, it will read it, then send a response.

light tapir
#

the OS deals with the details of it. for example ports, firewall, and so on

#

so in ur program u just make use of that os api and say u want to listen to tcp or udp traffic on port x

#

and then u get that traffic eventually from ur OS

brazen mist
light tapir
#

no, in ur router settings u configure all of that

#

via port forwarding

#

ur computer then receives the traffic and the OS will either know a program to forward it to or simply ignore the traffic if no program is interested in the traffic on that port

#

(and the firewall is also put before that)

brazen mist
#

where can i learn all this bro

pallid osprey
light tapir
#

u could spend decades on this topic alone

brazen mist
#

ah

pallid osprey
#

I welcome you to read it all, and it history to understand why it is like that.

light tapir
#

depending on how deep u want to go on what exactly

brazen mist
#

im 17

#

what should i learn

#

i just wanna make another website

#

but idk

#

what to make

pallid osprey
#

do you know how to do a static website?

brazen mist
#

html?

pallid osprey
#

I would say to you to start by a static github website

#

html + js + css

brazen mist
#

ah

#

i skipped to react

pallid osprey
#

its the same

brazen mist
#

yuh

pallid osprey
#

then start by having a github website

#

it is free

wet sandal
brazen mist
light tapir
#

its called "github pages"

#

pretty easy to use if ur a bit familiar with github

brazen mist
#

ah

#

im trying to be familiar with github

#

I reckon I can just learn it as I use it more

light tapir
#

as long as its "just frontend" without any backend, github pages will serve u very well

pallid osprey
#

your next step would be to have the same website, but with nginx and a reverse proxy like cloudflare

brazen mist
#

ive seen cloduflare but never really went deep into it

pallid osprey
#

nginx is a webserver that is very good at serving static website

brazen mist
#

the current website in my about me is made by me, I used my discord bot to show my discord status, but render went down after a few mins of inactivity so I used lanyard

pallid osprey
#

thing is you need to install it on a computer at home or in the cloud on a remote server

light tapir
# brazen mist what is cloudflare and nginx?

cloudflare is often used as protection layer. anyone visiting ur website has to first go through cloudflare. they check the traffic and block it if its malicious, shielding ur server. especially from DDoS attacks

brazen mist
#

ah thanks

#

How does it know whats malicious?

light tapir
#

it runs on so many websites worldwide that it analyzes the entire traffic and can spot large scale attacks that way

brazen mist
#

also is the cs job market really that bad or do people just like to say stuff

light tapir
#

depends a lot where ur at

brazen mist
#

I am in canada

wet sandal
#

it also add captcha

light tapir
#

in germany for example every cs student gets a job no problem

#

but as said, depends a lot on location

brazen mist
#

I see

#

How good is the pay

#

and is it really mentally draining

light tapir
#

dev salaries tend to always be in the "upper class" region

#

but might vary within that region

brazen mist
#

I see cs graduates from waterloo instantly go to faang companies

light tapir
#

but its pretty given that it will be enough to have a good life

brazen mist
#

in fact a family friend of mine instantly got to work at tesla right after graduation

light tapir
#

i personally never had a job that was bad or not fun

brazen mist
#

is it worth it to learn artifical intelligence

light tapir
#

i had one that i didnt like and just quit it

brazen mist
#

idk if I can count it as ai

#

what qualifies as ai

light tapir
wet sandal
brazen mist
#

yeah

light tapir
#

are u planning to study computer science? if so, ull learn everything u need anyways

brazen mist
#

yes I already got into a few unis, still waiting for better offers though

light tapir
#

i see. yeah, just follow their road and ull be well equipped knowledge wise with everything u need

brazen mist
#

I released an app on ios with over 140 downloads, is that good for my uni application?

#

I think it only gets impressive when I hit a few thousand downloads

light tapir
#

then, whether u want to aim for the stars or just get a normal job is up to u. either case, ull be having a good salary overall and the possibility to look for a job thats also fun

light tapir
#

there will always be people getting more than u. but whats ur goal. chances are ull be getting more than 70% of every other citizen even with the lowest dev salary

brazen mist
#

uhhh

#

i want atleast 500k salary

#

family friend from nvidia makes over 900k plus stock options

#

lucky guy

light tapir
#

so u want to become rich

brazen mist
#

fuck yeah

light tapir
#

i always just wanted to get enough to afford family, house and everything i need, while having a enjoyable life and fun at my job

brazen mist
#

well

#

I want enough money to unlock financial freedom

#

so I dont need to keep investing time into somthing I dont like

light tapir
#

u get that without being rich already

brazen mist
#

I dont wanan work a job bro

light tapir
#

anyone earning more than people at the bakery etc already get enough to afford life without thinking much about money

brazen mist
#

but to keep that life you have to keep working

light tapir
#

but if ur job is fun and enjoyable, where is the problem

brazen mist
#

I dont see how a job can be enjoyable

#

Im very bad at following schedules and I find them stressfull

light tapir
#

theres plenty of jobs without schedules and stress

#

hang out with friends, have fun, work on sth u enjoy

candid pendant
#

Is this thread still about networking or fantasies of living on a yacht? pepekek

light tapir
#

latter atm

brazen mist
#

but if I get rich and then get AP watches and fancy cars that is better

light tapir
#

ur still quite young and i dont want to shatter dreams. but ull be reaching a turning point with these thoughts eventually

brazen mist
#

frick

light tapir
#

its just very hard and generally unlikely to become rich

candid pendant
#

Zenny, don't get brainwashed by social media - it doesn't show you what reality actually is

brazen mist
#

I know

#

but how hard is it to get 500k salary

#

you guys make atleast 6 figures yes

pallid osprey
#

Your goal should be to make an enterprise.

#

But even then good luck not having to think about your work.

light tapir
#

my advice is to not think too much about that stuff when ur still so many years away from it anyways. have fun, enjoy ur time, walk on the path that leads u to a great life.
graduate. get ur first job, get ur second job, realize how things work, realize what is important to u in ur life, adjust goals, by 30 or 40 years ull found a sweetspot

brazen mist
#

a great life is a life where I dont have to work

light tapir
#

especially bc other countries have wildly different constellation

pallid osprey
brazen mist
light tapir
#

for example whether insurance is already included in the salary or not is one of those big differences that make it hard to compare numbers

pallid osprey
brazen mist
light tapir
#

the problem with startups is that u dont see how many of them fail

brazen mist
light tapir
#

startups are high risk high work high reward

brazen mist
#

I just wanna fuck around for a bit making one

light tapir
#

up to u ๐Ÿ™‚

brazen mist
#

do any of you guys know the game minecraft

light tapir
#

its just sad how many people with similar ideas ive seen in my years at this server who then showed up a few years later and failed

light tapir
brazen mist
#

but the path finding can prove to be difficult

#

what kinda math shall I learn for this to work

light tapir
#

so we get like half of what u get, pure salary wise

light tapir
#

everything is covered

brazen mist
#

did you already graduate uni

light tapir
#

in germany health and education is essentially free for everyone

brazen mist
#

same in canada

#

except not uni

#

uni still have to pay ofc

light tapir
#

here its essentially free

#

anyways

#

i get a typical senior salary

#

95k, which is about the money that a senior surgeon gets

#

so end of the normal high class range

brazen mist
#

mmmm

light tapir
#

i can afford life without having to look at my bank account

brazen mist
#

that is alot in germany

light tapir
#

its a normal dev salary for a senior

brazen mist
#

what does your company do?

light tapir
#

juniors 60k, intermediates 70k, seniors 80-100k

light tapir
#

its a classic java spring based backend job

brazen mist
light tapir
#

these exist like sand at the beach

light tapir
brazen mist
#

is it hard

light tapir
#

most people do (but its nit necessary)

brazen mist
#

whats the jump like from hs to uni

light tapir
brazen mist
#

yes it is

light tapir
brazen mist
#

well tahts how it is in hs too

#

how is the workload

light tapir
#

not in my experience

brazen mist
#

is it math heavy

light tapir
#

in school the teachers care for the individuals and will repeat sth if someone hasnt caught up yet

#

at university no one cares for the individual. ur sitting there with 100 other people and the prof is just forging ahead

brazen mist
#

I guess so

light tapir
#

less about calculating anything

brazen mist
#

no physics though correct?

#

I despise physics

light tapir
#

usually no physics

wet sandal
#

physics is cool

brazen mist
#

nope

light tapir
#

unless u pick sth like embedded systems engineering or microsystems or sth

brazen mist
#

I just go into cs so no physics

#

I can only tolerate math

wet sandal
brazen mist
#

i dont like it

#

just tolerate it

light tapir
#

its just completely different math. which is also why the dropout rate of math students is so super high

wet sandal
#

I don't like math ๐Ÿ™‚

light tapir
#

u learn why things work the way they do in the math world

#

instead of applying it

brazen mist
#

what kind of math?

light tapir
#

u learn how to prove sth, how to make theorems, how the people back then created their lemmas

#

instead of applying them

brazen mist
#

whats sth

light tapir
#

sth = something

#

its hard to describe. in school the teacher gives u a formula and u apply it

#

in university u learn everything needed to find such formulas on ur own

#

and prove their correctness

brazen mist
#

i dont like them

wet sandal
brazen mist
#

this guy coded his pathfidning from scratch

#

not using baritone at all I think

wet sandal
# brazen mist for real?

basic pathfinding is just a breath first search
more complex you have weights
and sure having a performant pathfinding over long distance is hard, but the basics are easy once you know how it workd

#

basics being :

brazen mist
mint fractalBOT
#

Graph traversal can be accomplished easily using BFS or DFS. The algorithms only differ in the order in which nodes are visited: https://i.imgur.com/n9WrkQG.png

The code to accomplish them is identical and only differs in the behavior of the Queue they are based on. BFS uses a FIFO-queue and DFS a LIFO-queue.

Queue<Node> nodesToProcess = ... // depending on BFS or DFS
nodesToProcess.add(rootNode); // add all starting nodes

Set<Node> visitedNodes = new HashSet<>();
while (!nodesToProcess.isEmpty()) {
  // Settle node
  Node currentNode = nodesToProcess.poll();
  if (!visitedNodes.add(currentNode)) {
    continue; // Already visited before
  }

  // Do something with the node
  System.out.println(currentNode); // Replace by whatever you need

  // Relax all outgoing edges
  for (Node neighbor : currentNode.getNeighbors()) {
    nodesToProcess.add(neighbor);
  }
}

To get BFS, use a FIFO-queue:

Queue<Node> nodesToProcess = new ArrayDeque<>();

And for DFS a LIFO-queue:

Queue<Node> nodesToProcess = Collections.asLifoQueue(new ArrayDeque<>());

Thats all, very simple to setup and use.

For directed graphs relax all outgoing edges.
For trees the visitedNodes logic can be dropped, since each node can only have maximally one parent, simplifying the algorithm to just:

Queue<Node> nodesToProcess = ... // depending on BFS or DFS
nodesToProcess.add(rootNode); // add all starting nodes

while (!nodesToProcess.isEmpty()) {
  // Settle node
  Node currentNode = nodesToProcess.poll();

  // Do something with the node
  System.out.println(currentNode); // Replace by whatever you need

  // Relax all outgoing edges
  for (Node child : currentNode.getChildren()) {
    nodesToProcess.add(child);
  }
}
brazen mist
#

Where can I learn these