move WSAStartup to init

WSAStartup should be called before using any other socket
functions. BindListenPort is not called if not listening.

Closes #2585.
Allow files to be opened for reading multiple times
Merge pull request #2586 from laanwj/2013_04_winsock_init

move WSAStartup to init
Try to increase file descriptor rlimit if necessary

As the default can be too low, especially on OSX.
Merge pull request #2569 from sipa/win1024fd

Allow select()ing up to 1024 file descriptors on Windows
Accept negative -par values to leave N CPUs free.
Merge pull request #2349 from dserrano5/master

Accept negative -par values to leave N CPUs free.
Merge pull request #2568 from sipa/rlimit

Try to increase file descriptor rlimit if necessary
Merge pull request #2589 from sipa/win32ldberr

Some win32-leveldb related fixes
Merge pull request #2583 from laanwj/2013_04_netbase_bitfield

netbase: fix !O_NONBLOCK where ~O_NONBLOCK was meant
Don't announce to non-peer CNodes
Merge pull request #2595 from sipa/noannloc

Don't announce to non-peer CNodes
RPC: strictly require HTTP URI "/"

Previously, JSON-RPC clients accessed URI "/", and the JSON-RPC server
did not care about the URI at all, and would accept any URI as valid.

Change the JSON-RPC server to require URI "/" for all current accesses.

This changes enables the addition of future interfaces at different
URIs, such as pull request #1982 which demonstrates HTTP REST wallet
download.

Or, a future, breaking change in JSON-RPC interface could be introduced
by serving JSON-RPC calls from new URI "/v2/".
Improve gettxoutsetinfo command

* Bugfix: output the correct best block hash (during IBD, it can
  differ from the actual current best block)
* Add height to output
* Add hash_serialized, which is a hash of the entire UTXO state.
  Can be useful to compare two nodes.
* Add total_amount, the sum of all UTXOs' values.
Bugfix: if no bestblock record is present, do a -rescan

It is possible to have a wallet.dat file without any bestblock
record at all (if created offline, for example), which - when
loaded into a client with a up-to-date chain - does no rescan and
shows no transactions.

Also make sure to write the current best block after a rescan, so
it isn't necessary twice.
Do not kill connections on recv buffer overflow

Instead of killing a connection when the receive buffer overflows,
just temporarily halt receiving before that happens. Also, no
matter what, always allow at least one full message in the receive
buffer (otherwise blocks larger than the configured buffer size
would pause indefinitely).
Exit cleanly if AppInit2 returns false

Bitcoin-Qt could core dump if application initialization failed in certain ways.

I double-fixed this:
1) qt/bitcoin.cpp now shuts down core threads cleanly if AppInit2 returns false
2) init.cpp now exits before StartNode() if strErrors is set (no reason to StartNode if we're just going to exit immediately anyway).

Tested by triggering all of the various ways AppInit2 can fail, either by passing bogus command-line arguments or just recompiling tweaked code to simulate failure.

This is a partial fix for #2480
Do not write to wallet during LoadWallet

When debugging another issue, I found a hang-during-startup race condition due to
LoadWallet calling SetMinVersion (via LoadCryptedKey).

Writing to the file that you're in the process of reading is a bad idea.
clear path cache after getting a proper config file (fixes #2605)

Signed-off-by: Jonas Schnelli <jonas.schnelli@include7.ch>
Merge pull request #2601 from jgarzik/uri-validate

RPC: strictly require HTTP URI "/"