Click here to Skip to main content
15,891,864 members
Articles / Desktop Programming / MFC

FiveLoaves v1.0

Rate me:
Please Sign up or sign in to vote.
3.84/5 (10 votes)
2 Jul 20028 min read 84.8K   4.4K   49  
FiveLoaves is an Internet utility designed to meet the most common needs of internet users - primarily secure connectivity
// define the correct flags for vncServer.h
#define _UBT_BUILD_ 
#ifdef _WIN32
 #define __WIN32__
#endif
#include "vncServer.h" // and include the RemoteWorkstation definitions




void ApplyStaticServerSettings( vncServer* pvncSrv )
{
	pvncSrv->SetQuerySetting(2); // 2
	pvncSrv->SetQueryTimeout(10); // 10
	pvncSrv->SetAutoIdleDisconnectTimeout(0); // 0
	pvncSrv->EnableRemoveWallpaper(1); // 1

//	pvncSrv->SetAuthRequired(0);
//	char encrypted[512];
//	vncEncryptPasswd("dad", encrypted);
//	pvncSrv->SetPassword(encrypted);

	// Now change the listening port settings
	pvncSrv->SetAutoPortSelect(1); //1
	pvncSrv->SetPort(0);
	pvncSrv->SockConnect(0); // 1
	
	// Set the CORBA connection status
	pvncSrv->CORBAConnect(0); // 0

	// Remote access prefs
	pvncSrv->EnableRemoteInputs(1); // 1
	pvncSrv->SetLockSettings(-1); // -1
	pvncSrv->DisableLocalInputs(0); // 0

	// Polling prefs
	pvncSrv->PollUnderCursor(0); // 0
	pvncSrv->PollForeground(1); // 1
	pvncSrv->PollFullScreen(0); // 0
	pvncSrv->PollConsoleOnly(1); // 1
	pvncSrv->PollOnEventOnly(0); // 0
}




extern DWORD g_servicethread;
extern BOOL g_servicemode;
int main(int argc, char * argv[])
{
	g_servicethread = GetCurrentThreadId();
	g_servicemode = TRUE;

	WSADATA wsaData;
	WSAStartup(MAKEWORD( 2, 2 ),&wsaData );

	SetProcessShutdownParameters(0x100, 0);
	vncServer server;
	
	

	
	struct sockaddr_in  serv_addr;
	int fd;
	int fdNew;
	struct sockaddr_in cli_addr;

	if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	{
		fprintf(stderr,"Can't open socket. \nCheck permissions \n");
		return 0;
	}
	memset((char *) &serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	serv_addr.sin_port = htons( 5900 );
	
	if(bind(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
	{
		printf("bind error\n");
	}

	int nn = listen(fd, 5);
	
	
	int one = 1;	
	int clilen = sizeof(cli_addr);
	while(1)
	{
		fdNew = accept(fd, (struct sockaddr *) &cli_addr, &clilen);
		if(fdNew < 0)
		{
			// error
		}
		else 
		{
//			char pBufRouteHeader[512];
//			int nBytes = recv(fdNew, pBufRouteHeader, 3, 0);
			
			ApplyStaticServerSettings(&server);		
			VSocket *new_socket = new VSocket;
		    new_socket->Attach(fdNew);
			setsockopt(fdNew, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one));
			server.AddClient(new_socket, FALSE, FALSE);
		}
	}
	
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Founder United Business Technologies
United States United States
http://about.me/brian.aberle
https://www.linkedin.com/in/brianaberle
http://SyrianRue.org/Brian

Comments and Discussions