Skip to content

maskrio/tutorial10-broadcast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reflection

2.1 Original code of broadcast chat

To run the server, we run cargo run --bin server and to run the client, we run cargo run --bin client

We have implemented a websocket communication between the server and the client. When any client sends a message, it will be broadcasted to all clients. We can see for each messages sent by a client, the message is broadcasted to all clients.

2.2 Modifying port

server.rs

let listener = TcpListener::bind("127.0.0.1:8080").await?;
println!("listening on port 8080");

We can modify the port by changing the port number at Server::bind function in the server code. We also have to change the port number where the client connects to in the Client::connect function.

server.rs will listen to the incoming connection to the address, the websocket connection will be initiated by the client. The server will accepts the incoming connections and handles the incoming messages.

2.3: Small changes, add IP and Port

We only have to the message at server to include the IP and the port from the client.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages