0

So, the question is in the following: How?

I have already implemented the TCP server on Python. It sends the data to a client(also implemented on Python).

So now I want to make it on JavaScript

Any reccomendations or suggestions?

1 Answer 1

1

You currently cannot connect to a TCP socket from plain JavaScript.

You have to rely on XHR or Websockets.

For more information see this answer.

Edit:

In Python you could use SocketIO to create a WebSocket. An example can be found here.

Sign up to request clarification or add additional context in comments.

5 Comments

but in case of using WebSockets- as I understood, I have to rewrite the server to work with the web sockets, not with the TCP?
Correct, see my edit for a WebSocket example in python.
Thanks a lot! I also have one more question: what about XHR? I have read about it, but according to my situation(need to get /on a client side/ and parse JSON-file) can I use it?
XHR uses the HTML protocol for its transfer. So you would have to support HTTP on your server :)
XHR uses the HTML - you, probably meant HTTP Ok, thanks a lot! I wish I could voteUp your answer:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.