1

So Im making a WebSocket Server in Python for my own purposes and I need to decypher the data recieved from the network. it's all in some jibberjabbish, can anyone help me figure out what it means?

while True:
    data = self.socket.recv(1024)
    print bytes(data)

that's my current code, though it just returns some weird characters. How do you make this into normal text? I have read the other topic on it, but the answers didn't help (were specific to his weird PHP stuff) and the links were dead.

2
  • Who is sending the data? Is the client written by you? Commented Jan 10, 2013 at 6:17
  • The client is an HTML page that use Google Chrome to test with. Commented Jan 10, 2013 at 20:00

3 Answers 3

1

If you want to implement a WebSocket server, you should be studying the WebSocket RFC in great detail. In particular, you want to be looking at section 4 which describes the initial request from the client to the server and the response the server must send, and section 5 that describes the way individual packets of data to or from the client are encoded.

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

1 Comment

Thank you, this helped me create a function that gets part by part and decodes to usable information
0

At default websockets using base64 encodings, so:

import base64
print base64.decodestring(message_from_socket)

2 Comments

and what client lib you use? SocketIO ?
i am using google chrome, but I have made a function using Screwtape's answer.
0

print bytes(data.decode())

Perhaps this might work? Sorry, its my first time answering here. And I know that I personally had to encode data before sending it, and then decode it when it arrives.

Comments

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.