Skip to content

Decompression not working #9

Description

When I try to decompress, I get the following error:

stream.js:46
  dest.on('drain', ondrain);
       ^
TypeError: Object  has no method 'on'
    at Socket.pipe (stream.js:46:8)
    at Server.<anonymous> (/home/hynese/backopt/server5.js:36:6)
    at Server.emit (events.js:64:17)
    at IOWatcher.callback (net.js:950:12)

Here is my code:

var net=require('net');
var sys=require('sys');
var compress=require('./node-compress/compress');

var gzip=new compress.Gzip;
var gunzip=new compress.Gunzip;
//gzip.init();
//gunzip.init();

var sourceport = 6999;
var destport = 7000;

net.createServer(function(s)
{
    var buff = "";
    var connected = false;
    var cli = net.createConnection(destport,'172.16.1.224');
    s.on('data', function(d) {
        if (connected)
        {
                sys.log("1");
                gunzip.init();
                cli.write(gunzip.inflate(d,"binary")+gunzip.end());
                //cli.write(d);
        } else {
           buff += d.toString();
        }
        //sys.log(d);
    });
    cli.on('connect', function() {
        connected = true;
        cli.write(buff);
    });
        sys.log("2");
        gzip.init();
        cli.pipe(gzip.deflate(s,"binary")+gzip.end());
        //cli.pipe(s);
}).listen(sourceport);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions