Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to make away that i can connect to my computer using port 2020. i made the login but i need to blind it to the port so when i login it will give me access to cmd on my computer, from my other computer in my office.

C++
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;

int main()
{
	system("COLOR 1E");
	string userName;
	string userPassword;
	int loginAttempt = 0;

	while (loginAttempt < 5)
	{
		system("CLS");
		cout << "Please enter your user name: ";
		cin >> userName;
		cout << "Please enter your user password: ";
		cin >> userPassword;

		if (userName == "test" && userPassword == "test")
		{
			system("CLS");
			cout << "Welcome Wolf!\n";
			break;
			system("PAUSE");
		}
		else
		{
			system("CLS");
			cout << "Invalid login attempt. Please try again.\n" << '\n';
			loginAttempt++;
			system("PAUSE");
		}
	}
	if (loginAttempt == 5)
	{
		system("CLS");
		cout << "Too many login attempts!";
		system("PAUSE");
	}
	system("PAUSE");
	return 0;
}


What I have tried:

i try finding a way online and i could not get the info i am after. ps. i have only started programing in C++. so i am not good at it.
Posted
Updated 24-Apr-18 8:25am
Comments
Rick York 24-Apr-18 20:32pm    
The word you are looking for is bind and it turns out that is exactly the function to call to make your program "listen" to a socket port. Here's is a sample of it from microsoft.

1 solution

Programming Windows TCP Sockets in C++ for the Beginner[^]
Socket Programming in C/C++ - GeeksforGeeks[^]

Of course you have some network connection between the two computers...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900