Browse Source

Add socket.address()

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
402755b14a
  1. 9
      lib/net.js
  2. 2
      test-net-server.js

9
lib/net.js

@ -335,6 +335,11 @@ Socket.prototype.connect = function () {
};
Socket.prototype.address = function () {
return getsockname(this.fd);
};
Socket.prototype.forceClose = function (exception) {
if (this.fd) {
this.readable = false;
@ -471,8 +476,8 @@ Server.prototype.listen = function () {
};
Server.prototype.sockName = function () {
return getsockname(self.fd);
Server.prototype.address = function () {
return getsockname(this.fd);
};

2
test-net-server.js

@ -28,7 +28,7 @@ var server = new net.Server(function (socket) {
sys.puts("server-side socket drain");
});
});
server.listen(8000, "localhost");
server.listen(8000);
sys.puts("server fd: " + server.fd);

Loading…
Cancel
Save