msysgit/git — pull request #150 by toshiyuki-ogawa (2014-04-04 05:03:00+00:00)
Title: To work server and client test program on Windows.

Now you can run client and server, and you can do following instructions.

1) compile client and server.
gcc -o server server.c -lws2_32 && gcc -o client client.c
2) run server and client.
./server 1337 & ./client 127.0.0.1 1337
3) You will get these output
[1]
Sleepint 1 second
I got the connection
[1]+ Done

--
This client server test do work well, even if server terminate before client terminate.
I think to need to make server be more similar to git-daemon.
1 git-daemon socket
On this commit, you can test socket status between client and server. However
server is not like git-daemon. Server itself write data to a socket, whereas
git-daemon make child-process write them to a socket as stdout.

1) server
1 client -- socket -> server

2 client <= socket == server
2) git-daemon
1 client -- socket -> git-daemon

2.1 git-daemon
* fork
2.2 git-daemon
* run-command
2.3 client <= socket ========= child process (git-uploadpack etc)

2 client, socket, stream and server
Not for sure, I think datagram is in any buffer of client, socket, stream and
server. If test data is too small, it will be arrived at client buffer soon.
Here is my image of buffer model.

fd(HANDLE) socket or network hardware
+--------+ +---------+
client:read -+ buffer +--+ bufffer +-+=+
+--------+ +---------+ |
+===========================+
| network
| +--------+ +--------+
+===+ buffer +-+ buffer +- write:server
+--------+ +--------+
| fd(HANDLE)
socket or network hardware

Signed-off-by: Toshiyuki Ogawa