Giter VIP home page Giter VIP logo

distributed-lab-1's Introduction

Distributed Lab 1: Go Chat Server

In this lab you will build a simple client-server chat system. To start with, you should follow the guide in this week's third Distributed Systems video to practice sending and receiving messages -- you should write this code yourself, and not use the templates in client and server, which are there for the second part of the lab.

Using the lab sheet

There are two ways to use the lab sheet, you can either:

Ratings

Each question is rated to help you balance your work:

  • ๐Ÿ”ดโšชโšชโšชโšช - Easy, strictly necessary.
  • ๐Ÿ”ด๐Ÿ”ดโšชโšชโšช - Medium, still necessary.
  • ๐Ÿ”ด๐Ÿ”ด๐Ÿ”ดโšชโšช - Hard, necessary if you're aiming for higher marks.
  • ๐Ÿ”ด๐Ÿ”ด๐Ÿ”ด๐Ÿ”ดโšช - Hard, useful for coursework extensions.
  • ๐Ÿ”ด๐Ÿ”ด๐Ÿ”ด๐Ÿ”ด๐Ÿ”ด - Hard, beyond what you need for any part of the coursework.

Part 1: Simple Client-Server Message-Passing ๐Ÿ”ดโšชโšชโšชโšช

Follow the video, creating a simple client and server that can send messages to each other. This is best tackled in stages. Again, you should write this code from scratch, as this part of the lab does not relate to the code in client and server. You may want to look at the net package for parts of this.

  • Stage 1: Achieve client-server interaction, with a server that listens for a single message and then prints it out and terminates, and a client that dials for a connection and sends a single message.

  • Stage 2: Modify the server so that it persists and handles new connections, printing out messages from any clients that connect.

  • Stage 3: Modify the client so it can send user-defined messages.

  • Stage 4: Modify both components so that the server sends replies to the client, which handles and displays them.

  • Stage 5: Create a fully interactive client-server loop, with the user prompted for input which is sent to the server and then acknowledged back to the client, without either component exiting or closing the connection.

Part 2: Chat Server ๐Ÿ”ด๐Ÿ”ดโšชโšชโšช

Using what you have learned so far on the course, fill out the client and server skeleton code to create a text-based chat system that handles multiple clients.

The client needs to (a) process user input and send it to the server on each newline; (b) at the same time, accept messages sent from the server and display them as they arrive.

The server needs to (a) handle new clients connecting; (b) process incoming messages from any connected client; (c) send any received message to all clients except the client that sent it.

The real test of your code will be to communicate with two or more clients via localhost, and see messages passing back and forth between them.

The skeleton code provides a starting point and some hints. You should use go run server.go to run the server, and go run client.go to run the client. The server accepts a -port flag to define a port to listen on, and the client accepts an -ip flag to define an ip:port string to connect to. By default the server launches on :8030 and the client connects to that port on localhost.

distributed-lab-1's People

Contributors

hamiltonrconnor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.