gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] TCP/IP connection built into GNU Go?


From: Inge Wallin
Subject: Re: [gnugo-devel] TCP/IP connection built into GNU Go?
Date: Wed, 13 Oct 2004 10:29:37 +0200
User-agent: KMail/1.6.2

On Monday 11 October 2004 11.31, Dave Denholm wrote:
> Gunnar Farnebäck <address@hidden> writes:
> >> The problem is that when you type `quit' and then try to make GNU Go
> >> listen on the same port again, it won't work. The system says the
> >> port is still in use. It gets released in about a minute (on my
> >> machine.) Clearly, something is not being closed, but I don't
> >> understand what it is. I doubt it could be a problem in `telnet'.
>
> That's a standard feature of sockets. If you run   netstat  after
> closing the connection, it will be in state TIME_WAIT (if it was
> closed cleanly)
>
> When you open the socket, you can specify an option (can;t remember
> detail off-hand - might be REUSE_ADDR  or LINGER)
>
> ISTR MS use REUSE_PORT rather than REUSE_ADDR ?

This problem is a standard problem in network programming, and even though it 
is not too difficult to find out how to solve it using the manuals, it is 
annoying.

Attached is the network functionality of a program that I have written that is 
a network server for generating opening books in a distributed fashion.  I 
have tried to remove as much domain-specific cruft as possible without 
cutting away things that are useful to you. Even though this program is not 
originally Open Source, feel free to use whatever part of this file as you 
want to.  This copy is hereafter officially under the GPL license.

Especially note the setting of socket options and the error-recovering and 
signal-handling loop around select(). I also have pretty well tested code to 
handle input- and output buffering.

        -Inge

PS
On second thought, I attached the client code as well.  Enjoy.



-- 
Inge Wallin               | Thus spake the master programmer:               |
                          |      "After three days without programming,     |
address@hidden       |       life becomes meaningless."                |
                          | Geoffrey James: The Tao of Programming.         |

Attachment: server.c
Description: Text Data

Attachment: client.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]