Improved handling of ephemeral ports

When using ephemeral port the actual port being used was not returned.
The socket.bind(String addr) method now returns correct port also for
ephermal ports.
Merge pull request #85 from cossin/master

Improved handling of ephemeral ports