mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
Fix style in test/simple/test-dgram-unix.js
This commit is contained in:
1 parent
294c455678
commit
f35a8298b1
1 file changed
+19
-14
@@ -1,43 +1,48 @@
|
||||
common = require("../common");
|
||||
assert = common.assert
|
||||
|
||||
var Buffer = require("buffer").Buffer,
|
||||
fs = require("fs"),
|
||||
dgram = require("dgram"), server, client,
|
||||
server_path = "/tmp/dgram_server_sock",
|
||||
client_path = "/tmp/dgram_client_sock",
|
||||
message_to_send = new Buffer("A message to send");
|
||||
fs = require("fs");
|
||||
dgram = require("dgram");
|
||||
|
||||
serverPath = "/tmp/dgram_server_sock";
|
||||
clientPath = "/tmp/dgram_client_sock";
|
||||
msgToSend = new Buffer("A message to send");
|
||||
|
||||
server = dgram.createSocket("unix_dgram");
|
||||
server.on("message", function (msg, rinfo) {
|
||||
console.log("server got: " + msg + " from " + rinfo.address);
|
||||
assert.strictEqual(rinfo.address, client_path);
|
||||
assert.strictEqual(msg.toString(), message_to_send.toString());
|
||||
assert.strictEqual(rinfo.address, clientPath);
|
||||
assert.strictEqual(msg.toString(), msgToSend.toString());
|
||||
server.send(msg, 0, msg.length, rinfo.address);
|
||||
});
|
||||
|
||||
server.on("listening", function () {
|
||||
console.log("server is listening");
|
||||
|
||||
client = dgram.createSocket("unix_dgram");
|
||||
|
||||
client.on("message", function (msg, rinfo) {
|
||||
console.log("client got: " + msg + " from " + rinfo.address);
|
||||
assert.strictEqual(rinfo.address, server_path);
|
||||
assert.strictEqual(msg.toString(), message_to_send.toString());
|
||||
assert.strictEqual(rinfo.address, serverPath);
|
||||
assert.strictEqual(msg.toString(), msgToSend.toString());
|
||||
client.close();
|
||||
server.close();
|
||||
});
|
||||
|
||||
client.on("listening", function () {
|
||||
console.log("client is listening");
|
||||
client.send(message_to_send, 0, message_to_send.length, server_path, function (err, bytes) {
|
||||
client.send(msgToSend, 0, msgToSend.length, serverPath, function (err, bytes) {
|
||||
if (err) {
|
||||
console.log("Caught error in client send.");
|
||||
throw err;
|
||||
}
|
||||
console.log("client wrote " + bytes + " bytes.");
|
||||
assert.strictEqual(bytes, message_to_send.length);
|
||||
assert.strictEqual(bytes, msgToSend.length);
|
||||
});
|
||||
});
|
||||
|
||||
client.bind(client_path);
|
||||
|
||||
client.bind(clientPath);
|
||||
});
|
||||
|
||||
server.bind(server_path);
|
||||
server.bind(serverPath);
|
||||
Reference in new issue
Block a user