Skip to content

Commit

Permalink
Added additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mdarl committed Sep 6, 2017
1 parent ca7fdc4 commit 26f0163
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ms3/src/cpp/MySocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void MySocket::bindSocket()
svrAddr.sin_port = htons(this->getPort()); //port (host to network conversion)
svrAddr.sin_addr.s_addr = inet_addr(this->getIPAddr().c_str()); //IP address
if ((bind(this->welcomeSocket, (struct sockaddr *)&svrAddr, sizeof(svrAddr)))
== SOCKET_ERROR) {
== SOCKET_ERROR) { //welcomeSocket is server's socket used to generate a connection socket for a client. Bind() maps it to the server's current IP Address. It is a single non-live socket.
closesocket(this->welcomeSocket);
WSACleanup();
std::cout << "Could not bind to the socket" << std::endl;
Expand All @@ -262,6 +262,7 @@ void MySocket::listenSocket()
}

void MySocket::acceptConnection() {
//connectionSocket is a single live connection between the server and a particular client. A server may have multiple connectionSockets.
if ((this->connectionSocket = accept(this->welcomeSocket, NULL, NULL)) == SOCKET_ERROR) {
closesocket(this->welcomeSocket);
WSACleanup();
Expand Down

0 comments on commit 26f0163

Please sign in to comment.