Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

To work server and client test program on Windows. #150

Merged
merged 1 commit into from
Apr 4, 2014

Conversation

toshiyuki-ogawa
Copy link

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 
  1. 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 [email protected]

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] <pid>
Sleepint 1 second
I got the connection
[1]+ Done

Signed-off-by: Toshiyuki Ogawa <[email protected]>
@buildhive
Copy link

MSysGit - the development behind Git for Windows » git #178 SUCCESS
This pull request looks good
(what's this?)

@linquize
Copy link

linquize commented Apr 4, 2014

Is the work related to #70?

@dscho
Copy link
Member

dscho commented Apr 4, 2014

@toshiyuki-ogawa thank you for the excellent work! I fear you are correct about the problem with the buffers.

The question is whether it is really worth it to modify server to behave more like git daemon, because we basically established that it is not as simple as I thought in the beginning.

However, I would like to reduce the amount of code added in #70. I think that there is good stuff there, but probably most of it is not needed to fix the problem.

Actually, thinking about it a little more, I think that the real problem might not be the socket at all, but the child: if the parent process goes away (or closes the socket) before the child process finished writing, we would see the same symptoms, right?

dscho added a commit that referenced this pull request Apr 4, 2014
To work server and client test program on Windows.
@dscho dscho merged commit 6204157 into msysgit:socket-test Apr 4, 2014
@toshiyuki-ogawa toshiyuki-ogawa deleted the win-client-server-test branch April 6, 2014 06:19
@toshiyuki-ogawa
Copy link
Author

@dscho I am glad to be helpful to you.

I understand that you are thinking child process of daemon. Why don't you write test code step by step? I do not hurry to solve the problem, but I want to make git-daemon be running without error. At the last pull request, I wrote a git-daemon fork, but I think that we don't have to make server fork. The reason is that windows do not offer 'fork' function, The 'fork' is replaced by 'CreateProcess'.

How about to modify server program bellow ?

  1. Create a executable which write some messages to stdout, In this context I call it 'clt_res' program.
  2. Add command line option to run 'clt_res' program. If you don't specify this option, you can test server in process. This modification will be done by calling 'CreateProcess'.
  3. (this is my proposal) Add command line option to specify how many messages server response. This option will be fill buffers between client and server.

@linquize I do this work for #70.

@dscho
Copy link
Member

dscho commented Apr 6, 2014

@toshiyuki-ogawa that sounds good! I won't have time this weekend, but should get to it mid-week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants