• Am working on the port of Espruino to an ESP8266 and have found something I am not understanding. If I form a TCP socket connection to a partner and the invoke the "end()" method on the socket I am finding that the request to disconnect doesn't actually happen until after I try and transmit something further. For example:

    var n = require("net");
    var s = n.connect({
          host: "192.168.4.2",
          port: 25867
    }, function(req) {
          print("Connected!: " + JSON.stringify(req));
          req.end();
    });
    

    doesn't cause the socket connection issued from the ESP8266 to be disconnected until I try the following:

    var n = require("net");
    var s = n.connect({
          host: "192.168.4.2",
          port: 25867
    }, function(req) {
          print("Connected!: " + JSON.stringify(req));
          req.end();
          req.write("We should be already disconnected");
    });
    

    Unfortunately, I don't have a real Espruino board to test against so I can't tell if this is how it works on the real Espruino or whether I have broken something in the ESP8266 implementation.

  • How would I test this?

    I'm happy to help, but I'm not sure how you test something like this.

  • @DrAzzy,
    Many thanks for the offer .... and I WILL take you up on it. Starting Sunday morning, I have to put my toys away for 2 solid weeks while I attend to other stuff, but from the end of September, onwards I'll be back on the project at full strength. At that time, I'll post detailed instructions to test. I may also splurge and buy an Espruino board just for testing ....

  • Just to add, if you do a native Linux compile (even on a VM) this is dead easy to test, as you get a standard linux binary that you can run from the command-line and debug.

  • Thanks Gordon, I'll shoot for a Linux compile for testing. Did you have any thoughts on the content of the original question? Is this expected behavior that when we form a connect and then issue an end() that it doesn't actually end the TCP connection at that time?

  • Just checked on linux and it's as you say (but even doing end(" ") fixes it) - so yes, it's a bug. I'll see what I can do about fixing it.

  • Ok, if you pull from GitHub now it'll be fixed.

  • Awesome ... thanks Gordon .. I'll be testing now.

  • I'm hoping to make a big push this month to make some good progress. Hopefully this will involve some well tested "Pull requests" from my clone of the "espruino/Espruino" project. However, I'm still somewhat new to GitHub and want to make sure I don't make a mistake. Here is what I have done so far.

    1. I went to Github: espruino/Espruino and executed a "Fork" which created nkolban/Espruino.
    2. I made small changes to this fork and issued a "Pull request" which was accepted.

    Now ... weeks have passed and I want to make sure that the "nkolban/Espruino" is still in synch with the "espruino/Espruino". Is there a mechanism/recipe/technique I should use to make sure that my fork is up-todate with "espruino/Espruino"?

  • GitHub has a doc on it here

    Once you've set up github.com/espruino/Espruino as your upstream repository it's pretty basic to just pull any changes I make and merge them in.

  • Thank you sir ... that looks straight forward enough.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Architecture: socket.end() doesn't disconnect until I write something

Posted by Avatar for Kolban @Kolban

Actions