Skip to content
← Back to Community
Is it possible to use python's socket library in repl.it?
Profile icon
ETHANSIAO

Hello,

(Quick disclaimer: this is a question about the feasibility using sockets in repl.it, not about how to use the library itself. Also, I'm definitely no expert whatsoever. Thanks!)

I've been trying to expand my own knowledge about python, and I've wanted to start learning more about online networks, clients, servers, etc. I've been watching a tutorial about python sockets here: https://www.youtube.com/watch?v=Lbfe3-v7yE0

After running the code demonstrated in the video, nothing happened. Is it possible to use python's socket library in (specifically) repl.it? I'm aware that javascript's socket library can work here, but I'm not quite sure about python's socket library.

If helpful, please see this code: https://repl.it/@ETHANSIAO/CheapDemandingDecompilers

Thanks for your time,

-E.S.

Answered by 21natzil [earned 5 cycles]
View Answer
Voters
Profile icon
JakubFabijan
Profile icon
OrigamiDrag0n
Profile icon
0xmmalik
Profile icon
ReDream
Profile icon
JohnWilliams2
Profile icon
OwenBradstreet
Profile icon
ETHANSIAO
Comments
hotnewtop
Profile icon
21natzil

Yes, and no. Yes you can create sockets, and they will behave normally. The problem with your code is that you're using gethostname. Replace that with "0.0.0.0" which means it will bind to the computer, but be accessible externally. The reason I say no, is that whenever you open a socket and bind it to the repl, repl.it is tricked into thinking you started an HTTP server (A web server). It will then start requesting your website, which may cause issues with your code. It will also convert any request other people made to the repl into HTTP.

Profile icon
ETHANSIAO

@21natzil Got it, thank you so much for the help!

Profile icon
OwenBradstreet

@21natzil How would you go about connecting to the server from another repl?

Profile icon
hg0428

I am trying this but it wont [email protected]