Is it possible to use python’s LIB socket to make communications as a websocket?

Asked

Viewed 85 times

0

Hello, sorry if there is any error, I am creating an MMORPG with the engine Construct 2 and it only has a plug-in websockets, however I tried to use the lib websockets from Python, but I don’t think it’s going very well due to my inexperience with this subject.

But I can’t find anything relevant on the internet about this lib including multiplayer game creations, I got the result I wanted by making a program with websocket, but it’s catching the client a lot, and I suppose the emulator is consuming a lot of RAM, lag only occurs when 2 or more players are connected.

Any help is welcome, from dirt using the lib websocket, examples, or indications of other libs, or other technologies other than Python, as I’ve used Node.js and I couldn’t because I couldn’t find something that had Thread in Node.js.

1 answer

2


Answering only the question "Is it possible to use python’s LIB socket to make communications as a websocket?" Yes - is it possible to.

After all, websockets are a higher-level protocol, which use sockets internally.

Now, if you ask if you "should" do this, the answer is a clear and audible nay.

And the logic for this is simple: when doing something with pure sockets, you have to take care of all the details yourself, directly in your code: how to know the sizes of each message, read and interpret connection start headers, and persist the status of each connection, manage multiple clients, and this list could continue for several other things that are solved when you use a higher level protocol that is already defined (in this case, the websockets), and there is already an implementation for this protocol (in this case, the websockets lib).

If this implementation of websockets is not good, and you are a person with a lot of networking experience, a lot of experience in at least one programming language, and at least an average knowledge of Python, so, yes, re-creating the functionality of websockets using pure sockets could be an interesting option. But note that only if you answer "yes" to the four things!

Given the continuation of your question, it seems that you have only considered the alternative because you have not yet found the best way to use the existing websockets library, and you imply that you are not an expert in network programming - so it is worth the "no", do not do this! :-)

Try, instead, create other, more specific questions, by putting complete code that people can use as an example, of what’s not working there for the people here to help.

  • Thanks !!! Got it here, after a fight I got it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.