Hi, Again,
I've created a tiny socket object that provides basic read/write
operations; which essentially boils down to the following:
var socketService = Components.classes["@mozilla.org/network/socket-
transport-service;
1"].getService(Components.interfaces.nsISocketTransportService);
var transport = socketService.createTransport(null, null, host, port,
null);
var inputStream = transport.openInputStream(0, 0, 0);
this.inputInterface = Components.classes["@mozilla.org/
binaryinputstream;
1"].createInstance(Components.interfaces.nsIBinaryInputStream);
inputInterface.setInputStream(inputStream);
outputStream = transport.openOutputStream(0, 0, 0);
outputInterface = Components.classes["@mozilla.org/binaryoutputstream;
1"].createInstance(Components.interfaces.nsIBinaryOutputStream);
outputInterface.setOutputStream(this.outputStream);
function read(bytes) {
return inputInterface.readBytes(bytes);
}
function write(msg) {
return outputInterface.writeBytes(msg, msg.length);
}
The protocol I'm trying to implement, specifies that all messges are
binary, encoded in the little-endian format. I am able to send
messages correctly using the write() method, but, for some reason,
read() calls fail. I *think* the write() calls are succeeding because
on observing WireShark's dumps, the 9P server responds with the
correct response message (Atleast the Hex dump of the response looks
Ok). However, I am unable to get that data via a read() call. Is it
because the response is encoded in little-endian? Why does the write()
call succeed, but read() fail when I am using readBytes/writeBytes in
both, which is supposed to deal with opaque binary data?
Thanks in advance.
Cheers,
--
Anant
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network