Ask coding questions

← Back to all posts
How do i make a repl that connects two people?
DarkClipton

Im working in python and i want to connect two or more people together But i never have made anything like this can someone please help me? Thanks

Voters
DarkClipton
Comments
hotnewtop
xxpertHacker

Depends on what they are going to do while "connected."

WebSockets and WebRTC are two common ways that I know of connecting people.

InvisibleOne

There are two ways to do it. The fist and best way (that I know of) is to make a server in python. Using socket to make a client and server.
The other way is to use a database that 'technically' has people doing stuff together but isn't really instant. You can use this for games with leaderboards and stuff, but if the players are supposed to interact with each other then you really need to use a server.

SixBeeps

@InvisibleOne ^ This right here. You'll likely need to learn about asynchronous code along the way, but sockets are the mainstream way of connecting two players through a live connection.

Myriad405

@SixBeeps But as far as I can tell, socket client and server repls cannot comunicate. So, really, db is the only way I can see working

InvisibleOne

I haven't done it in python, but socket servers work in Node.js I don't see why they wouldn't work in Python, the code is just a bit different @Myriad405

SixBeeps

@Myriad405 Can confirm, I have seen tons of Repls use Python with Sockets. Do they not work for you?

Myriad405

@SixBeeps I mean that I have built a socketserver repl and a socket client repl multiple times in Python, but they never were able to communicate. Now I thought that it may be an issue with my code, but I have found multiple users with the same issue/question.

Myriad405

@SixBeeps I asked the same question awhile ago on a different thread in which you responded you'd look at it, but I think you forgot about it. No offence :-)

Myriad405
Squirrel777

Just click share at the top right of you repl:

Then add somebody by their username or share the share link! Or are you talking about connecting multiple people with code?

DarkClipton

@Squirrel777 I mean for like a game without using pygame .-.

Squirrel777

Oh lol sorry I cant help with that, I use Javascript for backend @DarkClipton