Jump to content


Member Since 04 Oct 2013
Offline Last Active Today, 07:30 PM

#967565 C Https Socket programming

Posted by Sensei on 20 January 2017 - 10:37 AM

shutdown(socket,1) does the same thing.

Do you want to learn programming correctly, or not?
Any IT employer would tell you the same:
Don't use hard-coded integers, when they are defined as macros/enums.
And when they are not (your own code), make them, with meaningful names.

So I just need to add CRLF?? I dunno maybe there is a function on MSDN to generate it. The received header data doesn't have CRLF.

CRLF = Carrier Return, Line Feed,
They are two characters to add to strings returned to client by server.
Basically you do it by
printf( "Text....\r\n" );
\r is CR
\n is LF
\r\n is CRLF

Example HTTP response from HTTP server such as Apache:



After each line there is CRLF f.e. code in C/C++:

send(s,"HTTP/1.1 200 OK\r\n" );

send(s,"Content-Type: text/html\r\n" );

send(s,"\r\n" ); // empty CRLF

send(s,html_body_string );


No I didn't I read them and https://msdn.microso...3(v=vs.85).aspx trying to figure stuff out and it isn't exactly the same as what I want anyway since it's C++

In MSDN examples, C and C++ are pretty much the same, as they are not using C++ classes nor any C++ specific features.
They could simply call it "Example in C/C++" or "Ëxample in C".

  • 2

#967534 C Https Socket programming

Posted by Sensei on 20 January 2017 - 04:59 AM

   message = "Content-Type: Text/Css";
   send_all(new_socket, message, strlen(message));
   message = "body{background:blue;}";
   send_all(new_socket, message, strlen(message));



1st send_all() disabled sending (shutdown()) then how can you send 2nd time again after that?


shutdown() should looks like:

shutdown( socket, SD_SEND);


You didn't closesocket( new_socket );


You don't have proper HTTP-Response message..



Nor HTTP-Headers




They MUST have CRLF each line....

And being separated by empty CRLF from the main reply body..


It would be good for you to take some personal firewall with built-in sniffer (f.e. Sygate Personal Firewall),

or stand-alone TCP/IP packet sniffer, and try to connect from web browser to local installed Apache,

and look in TCP/IP packet viewer what is sent and what is received from proper HTTP server..


Look at MSDN

how nicely WinSock functions are described f.e.


On the bottom there are examples of how to use these functions, including error handling, which you ignored..

  • 1

#967368 Why quantum physics is a WASTE OF TIME

Posted by Sensei on 19 January 2017 - 04:37 AM

Why you know - I didn't know that Benjamin Franklin was a quantum physicist. I can't think of a single improvement in the art of electronic engineering due to any of the wild guesses of quantum physics beyond the existence of the electron.

1. Smoke detector is using radioactive isotope of Americium-241 produced in nuclear reactors..
(see applications section)
2. Laser
(and as a consequence CD/DVD/Blu-ray, Laser Distance Meters, etc. etc.)
3. LED (light emitting diode)
(and as a consequence LCD/LED/OLED screens etc. etc.)
4. photo elements.
photodiode https://en.wikipedia...wiki/Photodiode
photoresistor https://en.wikipedia...i/Photoresistor
5. Solar panels
6. Geiger counter
7. Decay of Plutonium-238 is used in RTG (Radioisotope thermoelectric generator) to create electricity for satellites flying in cosmos too far from the Sun to be able to use its energy.

Just a few examples, in random order of importance..

While the speeds of atoms or subatomic particles accelerating into a black hole may approach the speed of light that is theoretical since the only proof we have of the existence of black holes is conjecture due to hypothetical gravity fields.


If you look at center of our galaxy, you will see that stars are orbiting around nothing visible (in visible spectrum)..

  • 2

#967087 Donald Trump

Posted by Sensei on 17 January 2017 - 04:33 PM

(...) wasn't voting for Trump like shooting oneself in the foot?

Rather head-shot, in the middle...
Patient still alive, but end is pretty close..
  • 2

#967005 Massless things

Posted by Sensei on 17 January 2017 - 07:06 AM

Last time I checked, neutrinos were said to have a mass (tiny) because they seem to 'oscillate'. Do we have additional proofs in meantime? Is there now a firm knowledge that neutrinos have mass?...


I find it intriguing that we never observed a slow neutrino directly (or did we?) - can you shortly explain why is it so hard to find a slow neutrino?

Neutrinos/antineutrinos are detected when they interact with regular matter.

f.e. in Chlorine-based neutrino detector, there is used reaction:

^{37}_{17}Cl + v_e + 0.814 MeV \rightarrow ^{37}_{18}Ar + e^-

Relativistic mass/energy of neutrino capable to trigger this reaction must be equal or higher than 0.814 MeV.
If it's smaller, neutrino remain undetected. So the all neutrinos from proton-proton fusion in star are excluded by this detector!

  • 1

#966699 Acronym BB code broken?

Posted by Sensei on 15 January 2017 - 05:18 AM

I was re-reading the etiquette guide and I noticed the section about acronyms, the [acr] BB code doesn't appear to be functional.

Is this true for others, or is it just my browser? (Sony PS Vita.)

Like fiveworlds showed (without revealing details), it works. Just use full tag name.
Read this:
Click on 3rd button from the top-left (in full text editor), pick up Acronym from drop-down, and enter texts.

Anything that predates the last major update might not work anymore

He was suggesting that "Science Forums Etiquette" thread
should be updated (1st post, made by Cap'n Refsmmat).
[acr=Laughing Out Loud]LOL[/acr]
[ acronym=Laughing Out Loud]LOL[ /acronym]
to receive this:
  • 1

#966532 Theory about the universe

Posted by Sensei on 14 January 2017 - 01:45 AM

I was hoping to get some help from your genius brains but instead you accuse me of trolling.

We don't know where to start...
Go to primary school.. ?
Is it enough helpful?
  • 2

#966421 New gravity law

Posted by Sensei on 13 January 2017 - 04:45 AM

If your calculations disagree with experimental data, your "law" will be dismissed.
  • 1

#966420 Particles and Elements

Posted by Sensei on 13 January 2017 - 04:32 AM

So I understand that different combinations of particles, -particularly neutrons-, are essentially the equation that adds up to certain elements. My question being, so let's say you have an atom of Iron, with 77 neutrons.

Iron does not have 77 neutrons.
Iron has 26 protons,
in Fe-54 54-26= 28 neutrons,
in Fe-56 56-26= 30 neutrons.
These are the most abundant Iron isotopes.
Also stable are Fe-57 and Fe-58.

Would each neutron particle within the iron atom identify as being iron?

Element is defined by quantity of protons, not neutrons.

Number of neutrons in different isotopes is variable.

If nucleus has too much neutrons, it's unstable, and it will decay by neutron emission, alpha decay or the most typically by beta decay minus.
Rarely by double beta decay minus.

Or is a neutron particle simply a neutron particle regardless of the resulting atom?

Neutrons and protons are bound together in nucleus.
If nucleus has too few neutrons, it's also unstable (except H-1 and H-2), and will decay by proton emission, beta decay plus, eventually double beta decay plus, eventually electron capture.

If Iron nucleus would have too few neutrons, it couldn't exist, being extremely unstable. Basically unstable particle decays to more stable particle. It could be repeated until finding stability.
  • 1

#965853 For all Chess geniuses

Posted by Sensei on 9 January 2017 - 06:25 PM

As a chess player, this is ridiculous lol,

I completely agree. Title was "For all Chess geniuses"..
  • 1

#965243 Hydrogen, eternal element?

Posted by Sensei on 5 January 2017 - 11:06 PM

I understand that lead & iron are classed as stable elements,
but will eventually decay to Hydrogen/Helium. but will take trillions of years?

What is currently accepted (from observations), unstable isotope, or unstable particle,
spontaneously decays only when it has more mass-energy prior decay than after decay.

Sum the all mass-energy of protons and neutrons together:

m_{total}=m_p * Z + m_n * (A-Z)

m_p = 938.272 MeV/c^2

m_n = 939.565 MeV/c^2

And then subtract from it mass of Lead or Iron or whatever else you would like to examine.
You will have pretty large value, of missing energy (which was released during fusion).
It's called nuclear binding energy.


I understand that lead & iron are classed as stable elements,

There is dozen of unstable isotopes of Lead and Iron. Just some few are stable..

Bombard stable isotope by f.e. free neutrons,
and neutron can disintegrate isotope,
or there could be neutron capture,
and creation of unstable isotope, which will decay in future.
  • 1

#965040 living forever

Posted by Sensei on 5 January 2017 - 01:19 AM


Let's pull back on the stick a bit. Asking "What is stopping you?" is not the same as saying "You should do it!"


For somebody who is in depression and saying so on Internet forum/profile, and receiving comments like above, there is no difference..

  • 2

#964994 which occurs first lightning or thunder?

Posted by Sensei on 4 January 2017 - 07:51 PM

Sound travels approximately 340 m/s in air.
So if you see lightning and start counting seconds,
divide them by 3,
and you have distance to lightning in kilometers.

Suppose so you counted seconds to 5

d = v*t
d = 340 m/s * 5s = 1700 meters
  • 0

#964227 Energy of an electron

Posted by Sensei on 31 December 2016 - 01:01 PM

Suppose that there's an electron at rest removed from all gravitational sources and any other fundamental particles.

Any particle with rest-mass (unlike massless particles) can be at rest in its own rest frame of reference.

There is also such frame of reference, center of mass,
in which either object is moving.

Earth doesn't revolve around the Sun, but Earth revolve around center-of-mass of entire Solar System, so the same the all other planets.
Majority of the Solar system mass is in the Sun, so center-of-mass of Solar system is located close to the star core.
But in binary star system it could be not true anymore.

BTW, it's used to find out whether distant stars have planets.

  • 1

#963358 Iron in ocean to grow Plankton and capture CO2 in the atmosphere:

Posted by Sensei on 23 December 2016 - 11:02 AM

Plankton is eaten by sea living organisms, fishes, and they are absorbing Oxygen and releasing Carbon Dioxide while breathing.

  • 0