nc shows partial output
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm using busybox
v1.28.1 on an embedded device (armv7l). I want to use nc
to listen to TCP connections made by a javascript application (QML) on the same machine.
Here an example of the request:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);
// ...
post("http://127.0.0.1:55764", "Hello world");
From the console I run this command:
./busybox-armv7l nc -klv -p 55764
it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.
But this is the, werid, behavior I notice:
start server:
./busybox-armv7l nc -klv -p 55764
listening on [::]:55764 ...send the first packet:
connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)
3.send another packet:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764
Hello world
- now if I send other packets no more output is shown
Why?
EDIT
I changed the code like this:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);
and the script:
#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done
and it seems to work.
Do you see other evidence of errors?
tcp http javascript nc
add a comment |
up vote
0
down vote
favorite
I'm using busybox
v1.28.1 on an embedded device (armv7l). I want to use nc
to listen to TCP connections made by a javascript application (QML) on the same machine.
Here an example of the request:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);
// ...
post("http://127.0.0.1:55764", "Hello world");
From the console I run this command:
./busybox-armv7l nc -klv -p 55764
it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.
But this is the, werid, behavior I notice:
start server:
./busybox-armv7l nc -klv -p 55764
listening on [::]:55764 ...send the first packet:
connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)
3.send another packet:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764
Hello world
- now if I send other packets no more output is shown
Why?
EDIT
I changed the code like this:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);
and the script:
#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done
and it seems to work.
Do you see other evidence of errors?
tcp http javascript nc
1
I see a lot of odd things here. Your attempt to sendConnection: close
didn't work;Connection: Keep-Alive
was received instead. You claimed you were sendingx-www-form-urlencoded
data but you didn't urlencode the space. TheContent-Length
is wrong. You're making no attempt to reply to the HTTP request.
– Wumpus Q. Wumbley
Nov 18 at 2:34
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response withnc
.
– Mark
Nov 18 at 5:14
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using busybox
v1.28.1 on an embedded device (armv7l). I want to use nc
to listen to TCP connections made by a javascript application (QML) on the same machine.
Here an example of the request:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);
// ...
post("http://127.0.0.1:55764", "Hello world");
From the console I run this command:
./busybox-armv7l nc -klv -p 55764
it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.
But this is the, werid, behavior I notice:
start server:
./busybox-armv7l nc -klv -p 55764
listening on [::]:55764 ...send the first packet:
connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)
3.send another packet:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764
Hello world
- now if I send other packets no more output is shown
Why?
EDIT
I changed the code like this:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);
and the script:
#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done
and it seems to work.
Do you see other evidence of errors?
tcp http javascript nc
I'm using busybox
v1.28.1 on an embedded device (armv7l). I want to use nc
to listen to TCP connections made by a javascript application (QML) on the same machine.
Here an example of the request:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);
// ...
post("http://127.0.0.1:55764", "Hello world");
From the console I run this command:
./busybox-armv7l nc -klv -p 55764
it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.
But this is the, werid, behavior I notice:
start server:
./busybox-armv7l nc -klv -p 55764
listening on [::]:55764 ...send the first packet:
connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)
3.send another packet:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764
Hello world
- now if I send other packets no more output is shown
Why?
EDIT
I changed the code like this:
function post(url, data)
var xhr = new XMLHttpRequest();
var params = data;
var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");
timer.triggered.connect(function()
xhr.abort();
);
xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);
;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);
and the script:
#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done
and it seems to work.
Do you see other evidence of errors?
tcp http javascript nc
tcp http javascript nc
edited 2 days ago
asked Nov 17 at 21:29
Mark
1389
1389
1
I see a lot of odd things here. Your attempt to sendConnection: close
didn't work;Connection: Keep-Alive
was received instead. You claimed you were sendingx-www-form-urlencoded
data but you didn't urlencode the space. TheContent-Length
is wrong. You're making no attempt to reply to the HTTP request.
– Wumpus Q. Wumbley
Nov 18 at 2:34
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response withnc
.
– Mark
Nov 18 at 5:14
add a comment |
1
I see a lot of odd things here. Your attempt to sendConnection: close
didn't work;Connection: Keep-Alive
was received instead. You claimed you were sendingx-www-form-urlencoded
data but you didn't urlencode the space. TheContent-Length
is wrong. You're making no attempt to reply to the HTTP request.
– Wumpus Q. Wumbley
Nov 18 at 2:34
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response withnc
.
– Mark
Nov 18 at 5:14
1
1
I see a lot of odd things here. Your attempt to send
Connection: close
didn't work; Connection: Keep-Alive
was received instead. You claimed you were sending x-www-form-urlencoded
data but you didn't urlencode the space. The Content-Length
is wrong. You're making no attempt to reply to the HTTP request.– Wumpus Q. Wumbley
Nov 18 at 2:34
I see a lot of odd things here. Your attempt to send
Connection: close
didn't work; Connection: Keep-Alive
was received instead. You claimed you were sending x-www-form-urlencoded
data but you didn't urlencode the space. The Content-Length
is wrong. You're making no attempt to reply to the HTTP request.– Wumpus Q. Wumbley
Nov 18 at 2:34
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with
nc
.– Mark
Nov 18 at 5:14
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with
nc
.– Mark
Nov 18 at 5:14
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482403%2fnc-shows-partial-output%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I see a lot of odd things here. Your attempt to send
Connection: close
didn't work;Connection: Keep-Alive
was received instead. You claimed you were sendingx-www-form-urlencoded
data but you didn't urlencode the space. TheContent-Length
is wrong. You're making no attempt to reply to the HTTP request.– Wumpus Q. Wumbley
Nov 18 at 2:34
Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with
nc
.– Mark
Nov 18 at 5:14