mirror of https://github.com/lukechilds/node.git
Browse Source
setImplementationMethods checks the type of a socket and defines different behavior based on the type, so auto detect it if type not implicitly specified.v0.7.4-release
Daniel Ennis
14 years ago
committed by
Ryan Dahl
3 changed files with 128 additions and 4 deletions
@ -0,0 +1,24 @@ |
|||
var assert = require('assert'); |
|||
var net = require('net'); |
|||
var common = require('../common'); |
|||
|
|||
var server = net.createServer(); |
|||
|
|||
//test unix sockets
|
|||
var fds = process.binding('net').socketpair(); |
|||
var unixsocket = new net.Socket(fds[0]); |
|||
assert.ok(unixsocket.type == 'unix', 'Should be UNIX'); |
|||
|
|||
//test that stdin is default file
|
|||
assert.ok(process.stdin.type == 'file', 'Should be File'); |
|||
|
|||
//test tcp sockets.
|
|||
server.listen(function() { |
|||
var client = net.createConnection(this.address().port); |
|||
client.on('connect', function() { |
|||
var newStream = new net.Socket(client.fd); |
|||
assert.ok(newStream.type == 'tcp', 'Should be TCP'); |
|||
client.destroy(); |
|||
server.close(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue