« first day (1900 days earlier)      last day (959 days later) » 

5:42 AM
Trying to `send(…)` this HTTP message across to `www.example.com` using the Windows Sockets 2.0 API 🌐
```
"GET /index.html HTTP/1.1" "\r\n" "\r\n"
```
```
GET /index.html HTTP/1.1

```
but keep `recv(…)`ing this response and have no idea how to diagnose it 🤷🏾‍♂️
```
HTTP/1.1 400 Bad Request
Content-Type: text/html
Content-Length: 349
Connection: close
Date: Thu, 23 Sep 2021 05:00:45 GMT
Server: ECSF (mic/9B4A)
```
```
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
 
1 hour later…
6:48 AM
@Lapys maybe add one of the typical fields that some web servers require like "Host"
 
@PeterT Not too familiar with HTTP header fields but tried something like that earlier and still got the same output 🤔
 
you're supposed to put in the target host in the HOST field
not your own hostname
like www.example.com in your case
so that one IP can serve multiple hosts
 
Oh, wow. That worked
Thank you, @ PeterT 💪🏾
 
 
5 hours later…
12:11 PM
Is `inline` meaningful for template functions(not include fully specified template functions)?
I carefully read https://stackoverflow.com/questions/10535667/does-it-make-any-sense-to-use-inline-keyword-with-templates. But I still can't find a direct answer.
 
 
1 hour later…
1:39 PM
Working with posix mutex one of the thread got deadlocked but when we print mutex in gdb everything is 0.

{__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {
__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}

Above looks strange if someone has already taken the lock then atleast something should be greater than 0 and even if no one has taken the lock atleast __kind should have something other than zero or atleast something should be set.
 
1:49 PM
Never depend on the internal structure of a lock?
 
2:01 PM
Thanks @Mgetz
 
nwp
2:29 PM
@John What is your definition of "template function"?
 
 
3 hours later…
5:47 PM
struct Test {
  int x;
};

int main() {
  for (int i = 0; i < 3; ++i){
    Test t;
    if(i == 0){
      t.x = 5;
    }
    std::cout << t.x << " ";
  }
}
why is the output 5 5 5?
(I understand you are supposed to initialize t, but why? whats the compiler doing?)
 
nwp
According to the standard it's undefined behavior. You are not allowed to read values you have not initialized.
In practice the compiler will put the ts you create and destroy at the same position each loop iteration and see that the constructors and destructors of Test don't do anything. So the first iteration sets t.x = 5 and the next iterations read memory that happens to have a 5 in it.
But you cannot rely on it. If you use sanitizers chances are the program will crash with a "You read uninitialized memory" error. Also some compilers are very cheeky and see that only the first iteration is defined so they will simply optimize out the loop and it might only print 5 once. Or it just returns from main immediately.
 
Is it better to initialize t or add default values to the struct definition?
 
nwp
Generally yes. There should be no overhead because if you overwrite the default value before reading it the compiler should see a dead write and eliminate it.
 
Cool
thanks
 
 
3 hours later…
8:48 PM
@sehe so for the connection class, would it be possible for that to be an interface?
and then pass that in as a template arg just like the MsgId?
so that I can create additional variables and things on the connection?
or should that be a separate thing
where I handle that in my TCPServer class
as a map of int(client id) and customclientstruct
 

« first day (1900 days earlier)      last day (959 days later) »