示例#1
0
文件: main.cpp 项目: lleonini/splay
/*
	 An SSL server that is started from the console.

	 This example demonstrates the use of the QtSSLSocket class in a
	 server application.
	 */
int main(int argc, char *argv[])
{
	QFileInfo cert("sslserver.pem");
	if (!cert.exists()) {
		qDebug("Note: This server requires the file sslserver.pem to exist, "
				"and to contain the SSL private key and certificate for "
				"this server, encoded in PEM format. Please read "
				"server.txt for more information.");
		return 1;
	}

	if (argc < 2) {
		qDebug("usage: %s <port>", argv[0]);
		qDebug("A simple SSL server.");
		return 1;
	}

	QApplication app(argc, argv, false);

	int port = atoi(argv[1]);

	SSLServer sserver(port);

	qDebug("Listening on port %i. Please press Ctrl-C to exit.", port);

	return app.exec();
}
示例#2
0
int main(void)
{
	// Buffer for client data.
	int len = BUFFERSIZE;
    char *buf = new char[len]; 
    SelectServer sserver(PORT, buf, len);
	
	sserver.Start(BACKLOG);
   
    return 0;
}
示例#3
0
//instead of server_bind and server_listen we could use 
//server_connect
int server_connect(int portno)
{

    /* Create client socket */ 
    if (!fSocket) {
      fSocket = sopen();
    }

    printf ("socket fSocket %p\n", fSocket);
    if ((sockfd = sserver(fSocket, portno, S_DELAY)) >= 0) {
//      fConnected = 1;
      return 0;   //good
    }

    if (fSocket) sclose(fSocket);

    return -1;  //not good
}