[net2] lower-case socket.type
This commit is contained in:
parent
25700e65ee
commit
48ccbb9afa
26
lib/net.js
26
lib/net.js
@ -284,10 +284,12 @@ Socket.prototype.connect = function () {
|
||||
if (self.fd) throw new Error('Socket already opened');
|
||||
|
||||
if (typeof(arguments[0]) == 'string' && arguments.length == 1) {
|
||||
self.fd = process.socket('UNIX');
|
||||
self.fd = socket('unix');
|
||||
self.type = 'unix';
|
||||
// TODO check if sockfile exists?
|
||||
} else {
|
||||
self.fd = process.socket('TCP');
|
||||
self.fd = socket('tcp');
|
||||
self.type = 'tcp';
|
||||
// TODO dns resolution on arguments[1]
|
||||
}
|
||||
|
||||
@ -386,14 +388,22 @@ exports.createServer = function (listener) {
|
||||
};
|
||||
|
||||
|
||||
// Listen on a UNIX socket
|
||||
// server.listen("/tmp/socket");
|
||||
//
|
||||
// Listen on port 8000, accept connections from INADDR_ANY.
|
||||
// server.listen(8000);
|
||||
//
|
||||
// Listen on port 8000, accept connections to "192.168.1.2"
|
||||
// server.listen(8000, "192.168.1.2");
|
||||
Server.prototype.listen = function () {
|
||||
var self = this;
|
||||
if (self.fd) throw new Error('Server already opened');
|
||||
|
||||
if (typeof(arguments[0]) == 'string' && arguments.length == 1) {
|
||||
// the first argument specifies a path
|
||||
self.fd = process.socket('UNIX');
|
||||
self.type = 'UNIX';
|
||||
self.fd = socket('unix');
|
||||
self.type = 'unix';
|
||||
// TODO unlink sockfile if exists?
|
||||
// if (lstat(SOCKFILE, &tstat) == 0) {
|
||||
// assert(S_ISSOCK(tstat.st_mode));
|
||||
@ -401,14 +411,14 @@ Server.prototype.listen = function () {
|
||||
// }
|
||||
bind(self.fd, arguments[0]);
|
||||
} else if (arguments.length == 0) {
|
||||
self.fd = process.socket('TCP');
|
||||
self.type = 'TCP';
|
||||
self.fd = socket('tcp');
|
||||
self.type = 'tcp';
|
||||
// Don't bind(). OS will assign a port with INADDR_ANY. The port will be
|
||||
// passed to the 'listening' event.
|
||||
} else {
|
||||
// the first argument is the port, the second an IP
|
||||
self.fd = process.socket('TCP');
|
||||
self.type = 'TCP';
|
||||
self.fd = socket('tcp');
|
||||
self.type = 'tcp';
|
||||
if (needsLookup(arguments[1])) {
|
||||
getaddrinfo(arguments[1], function (ip) {
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user