top of page

C++ Winsock System

Platform: PC - Windows Console Application

Theme: Server & Client Texting System

Time Frame: 1 Week

My Role: Solo Project - Programmer

Software: Visual Studio 2017

Language: C++

This project was for an assignment for my 'Advanced Programming' module in my third year at uni. Throughout the first semester (Sep - Dec) we learned content on Advanced C++ programming.  Part of this content was about setting up a server using ports and sockets. After learning how this content worked in just a main function of a C++ application, our assignment was to convert that code so that it was class based, and then also making it a messaging service between a client program and server program along with error handling.

​

The System

The project consists of 3 classes and the main file. These Classes are; Comms, Client, Server. Client and Server are both sub-classes of Comms, the reason for this is because they both share the same setup process, this process / block of code has been put into a member function of Comms called 'Setup', this function searches for the winsock dll within the project, and then sets up the socket that the connection between server and client will both use.

The Server class has a Bind function, this will bind the program to using a available Port and then begin to wait for a client connection. Once the connection is found (client launches application), it will accept the connection and begin waiting for a message.

The client has a Connect function, this will run after Setup, if no server program is running then it will fail and exit, if there is a Server, then it will connect to the socket that has been allocated and will allow the client to send a message to the Server. The server can then respond and vise-versa until the client types "QUIT", then the application will close.

​

CODE SNIPPETS

bottom of page