Skip to content

bob1113/tcp-number-guessing-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCP number guessing game

Table of contents

About the project

Tis is a number guessing game based on TCP socket. The server side allows clients to guess a number between 0 to 999, and replies a guessing result, on the other hand, the client side can access the server, guess a number, and read the result replied by the server. Since this project is implemented by Windows Sockets API, it can only run on Windows system, but one shall be able to modify it into a Linux/Unix system version easily.

Built with

  • Windows Sockets API

(back to top)

How to run this project

Prerequisites

Loopback adapter is a network interface that can be used to route network traffic from one application to another on the same computer, but does NOT send that traffic to any other device on the network, which is useful to observe the behaviors on both server side and client side with only one Windows-system computer.

Wireshark is a free and open-source packet analyzer, one may use it to observe the communication between server and client in this project.

Installation and simulation

To get a local copy up and running follow these simple steps.

  1. Clone the repo

    git clone https://github.com/bob1113/tcp-number-guessing-game.git
  2. Compile the ser.cpp and cli.cpp files

    g++ -o cli cli.cpp -lws2_32
    g++ -o ser ser.cpp -lws2_32
  3. Initialize server and client
    Open two powershell windows, one for server side, and the other for client side.

    Server

    .\ser 5555

    Client

    .\cli 127.0.0.1 5555
    Game start Guess number Correct guess

Remarks

The number used in .\ser 5555 is the port number that server and client communicate with, and the address 127.0.0.1 means that the client communicate with the server through loopback adapter, i.e., sending and receiving packets on the same computer.

(back to top)

Acknowledgments

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Bob Lai - [email protected]
Project Link - https://github.com/bob1113/tcp-number-guessing-game

(back to top)

About

A TCP client/server application developed by WinSocket.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages