UI tweaks, use BindListenPort to detect instance already running, setsockopt(SO_REUSEADDR) so can bind during TIME_WAIT after exit and restart

git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@35 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
s_nakamoto
2009-11-07 05:05:03 +00:00
parent 8acda009d9
commit 8b4cefd324
11 changed files with 366 additions and 304 deletions

6
net.h
View File

@@ -28,6 +28,7 @@ CNode* FindNode(unsigned int ip);
CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
bool AnySubscribed(unsigned int nChannel);
bool BindListenPort(string& strError=REF(string()));
bool StartNode(string& strError=REF(string()));
bool StopNode();
@@ -456,6 +457,8 @@ extern CNode* pnodeLocalHost;
extern uint64 nLocalHostNonce;
extern bool fShutdown;
extern array<int, 10> vnThreadsRunning;
extern SOCKET hListenSocket;
extern vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
extern map<vector<unsigned char>, CAddress> mapAddresses;
@@ -647,8 +650,7 @@ public:
void EndMessage()
{
extern int nDropMessagesTest;
if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0)
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
printf("dropmessages DROPPING SEND MESSAGE\n");
AbortMessage();