Beispiel #1
0
/*------------------------------------------------------------------------
 * main - TCP client for ECHO service
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
	char	*host = "localhost";	/* host to use if none supplied	*/
	char	*portnum = "5004";	/* default server port number	*/

	/* SSL initializations */
	SSL_CTX *ctx;

	/* Load encryption & hashing algorithms for the SSL program */
	SSL_library_init();

	/* Create and load ctx struct to authenticate server certificate */
	ctx = create_CTX_to_authenticate(); 

	switch (argc) {
	case 1:
		host = "localhost";
		break;
	case 3:
		host = argv[2];
		/* FALL THROUGH */
	case 2:
		portnum = argv[1];
		break;
	default:
		fprintf(stderr, "usage: TCPecho [host [port]]\n");
		exit(1);
	}
	TCPecho(host, portnum, ctx);
	exit(0);
}
/*------------------------------------------------------------------------
* main - TCP client for ECHO service
*------------------------------------------------------------------------
*/
void main(int argc, char *argv[])
{
	char firstHost[15] = "192.168.40.50"; //Defines the first host to check if it is running a server application.
	char	*host = firstHost;	 //Sets a pointer equal to the host, for manipulation and function passing purposes.
	char	*service = "echo";	//Defines the service. This will use echo.
	WSADATA	wsadata; //Used to initialize WinSock2 and open sockets
	SetConsoleTitle(L"Client End"); // Sets the title of the application.

	if (WSAStartup(WSVERS, &wsadata) != 0) // Attempts to start WSA, if failed, it will pull an error code. If it doesn't fail, it returns 0.
	{
		errexit("WSAStartup failed\n"); // If failed, prints it fails, and shuts down WinSock2. It fails whenever the program is already open. It protects against initializing twice.
	}
	printf("Searching for server on 192.168.xxx.xxx\n"); // Starts searching on the private network.
	TCPecho(host, service); //Function initializer, with the initial host, and the service type.
	WSACleanup(); // Closes all open sockets and shuts down WinSock2.
	exit(0); // Exits the program.
}
Beispiel #3
0
/*------------------------------------------------------------------------
 * main - TCP client for ECHO service
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
	char *destination;
	int  portN;

	if (argc==3)
	{ 
	  destination = argv[1];
	  portN = atoi(argv[2]);
	}
	else usage(argv[0]);
		
	TCPecho(destination, portN);

	exit(0);
}
Beispiel #4
0
/*------------------------------------------------------------------------
 * main - TCP client for ECHO service
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
        char    *host = "localhost";    /* host to use if none supplied */
        char    *service = "echo";      /* default service name         */

        switch (argc) {
        case 1:
                break;
        case 3:
                service = argv[2];
                /* FALL THROUGH */
        case 2:
                host = argv[1];
                break;
        default:
                fprintf(stderr, "usage: TCPecho [host [port]]\n");
                exit(1);
        }
        signal(SIGPIPE, SIG_IGN);
        TCPecho(host, service);
        exit(0);
}
Beispiel #5
0
/*------------------------------------------------------------------------
 * main - TCP client for ECHO service
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
	char	*host = "localhost";	/* host to use if none supplied	*/
	char	*portnum = "5004";	/* default server port number	*/

	switch (argc) {
	case 1:
		host = "localhost";
		break;
	case 3:
		host = argv[2];
		/* FALL THROUGH */
	case 2:
		portnum = argv[1];
		break;
	default:
		fprintf(stderr, "usage: TCPecho [host [port]]\n");
		exit(1);
	}
	
	TCPecho(host, portnum);
	exit(0);
}