I'd let's begin with the chat up now so we can create a chat up by saying you package and let me create
chat up here.
So in this particular chat up let me say new place and find Of course it's going to be a client and
there's going to be a civil.
Things are pretty much the same but of course when we do it more number of times you will be more familiar
with it.
What we are trying to do so we can close up all the other applications for multi-threading chat chat
chat app.
This is the kind of server chat.
OK.
Networking Sure.
So we calls all of them just declined and server for chat.
This is started let's say in the client that we buy.
Let me say compote let me call it simple.
So we have of course I need to import socket.
Things are pretty much the same but we got to do that again so that you want to set a very well socket
that socket create a client socket plate.
So we call the CSR now plain socket and server socket is going to be in both socket.
So as to be in to suck it I will say sucking cock sucking right.
Sure.
Let me call this this.
SS That's a service.
Okay now.
SS Daut of course you need to find it.
And after finding them you need to say to start listen listen for clients but now.
Now comes the question I cannot I cannot connect to one plane because my server now will connect to
multiple clients.
I want to make a chat with many clients talking to each other see one client here.
One client here one client here lets see each of them want to talk to each other.
Why so.
So there's a sober in-between.
And each of them are going to talk to each other just like the picture that we just saw.
So you're going to have client one client to client required for one to have four clients each of them
want to communicate with each other or chat with one another writer or whatever the sclayn say is let's
say this is ABC whatever he sends should be displayed on the screens of all the three by saying ABC
said this and they say this client's name the x y z and he sends a message displayed on these lines
as x y z said this so you should have multiple clients talking to each other.
Why are the soaps.
So you're basically broadcasting messages.
So that's what you're going to do.
So.
So you cannot just say connect to you know accept a particular client out here you can do that rather
rather.
Now what we're going to do is because we need to keep accepting clients once again again and again there
can be multiple clients I need to say.
SS Right.
I need to keep I need to keep getting these multiple questions out there so I'm going to say esus dot
dot except OK.
So here I'm going to accept multiple clients let me call this kind.
Come a ADR.
Right.
So I'm going to say you know I'm just going to print.
Got a connection
from client and address Comox come an 18 year break.
So I printed that up and then I say out here are we here you say print after they print this up like
we call it is after printing them.
I'm going to say look at the connection I need to store this particular content.
At least this address along with a name.
So what I'll do is at the client side after they connect OK so I'm going to connect so I'm going to
say she has done so I'm going to connect to.
Of course I'm going to connect to localhost come on the address let me say post-combat 2000.
The server has not been bound to bind it to 2000
right after you buy it.
And you're going to get some data which you need to after you connect to the particular server you need
to do one thing that is send send your you don't take input from the user whenever the client comes
just taking input from the user and enter your name.
So when the client enters you know you ask him his name.
Store that name and when you get the name or you can do as you can the minute you connect send it to
the server send to the server saying saying what the senders name so name thought and code centered
as bytes is a string so encoded is bytes and just send it to the server which means the server the minute
it gets a connection from the client.
The next thing is it should wait for it.
It should get some data.
It should you should receive some data around thousand bytes receive it.
Store it and store it in name of the client that has just come.
OK.
Now when this happens what you can do is he can start a trade.
Let me call this trade.
He's equal to trade.
Let me call this a trade and let's say I'm going to pass these parameters.
OK so I'm going to say Target target he called to let me call this client underscore task.
I'm going to call call functions or cleanse task which means I need to have a function out here.
Then we Cardus desk climb and score that task.
And of course trading Also I need to import from trading impose trade
rights so I create this task and after I had that particular target.
So I need to go along with clients that let me pass a few arguments.
Let me pause the client name right the client address right.
And and the connection of course you require the connection.
So let me call it S. Klein.
KLEIN
So accepted these three things which means I need to send these as arguments are GSC equal to a couple
of these three.
So do I have each of them.
Yes I have name I have as one of the arguments I have kyne and I have ADR which can be passed.
These three can be passed as arguments to those three.
Right.
So I can create this thread and all and it was that stopped.
Correct.
That will start the particular but of course all instead of name it should be because the name that
you receive is going to be in bytes.
I should do.
Name dot de-code and then send it out.
So decoded and then send it up.
So that's cool.
And then the one task you can do whatever the class or whatever it's doing you know whatever it wants
to do.
OK so if the client has each of the Cline's are going to be on different thread altogether.
So the client tasked each of them is going to be different.
Right.
So because each of them one when new threats are created and client task is called so each client is
going to have a separate.
Each client is going to have a separate client task.
And that let's say we're going to use these arguments we're going to what we're going to do is of course
we have to do just the client asks only this much.
Whatever they get from one client send it to all the clients.
So let's say I have to receive.
So basically I need to have a while to cheer and then keep receiving from whatever's the connection.
So let me say Klein kind dot receive receive Let's say I received thousand bytes of data.
So.
So let me say data which I guessed.
OK that data is going to be I need to send it to all the other clients so basically I need to get this
data and I need to send it to all the other clients.
Oh but I don't know the other clients right.
You know I didn't know when I come to a particular client us do I have the connections of all the other
clients.
No I don't have hands I need to store these particular clients the minute I get a client I need to store
them in a dictionary.
Right.
Create a dictionary let me call them clients.
I'll create a simple dictionary of clients.
We're just going to be empty at the start but the minute I get a particular client I should.
What I can do along with the name.
Once I get it I should add that in the dictionary.
So I take clients off.
I give out one of the name that I've got.
OK so name not just names should be named logicals sorry.
So the name that de-code Klein's name but de-code I should say that should be called to I should be
make it equal to the two let's say and send in the values with the connection right.
So that.