
PowerTCP WebServer for ActiveX
Overview Build web applications in any familiar software development environment. Use WebServer for ActiveX to add web-based access to traditional compiled applications. WebServer ActiveX control accepts HTTP and HTTPS connections, turning ANY application into a custom Web Server. Control security aspects of HTTPS. Events are raised as HTTP requests arrive, with default operation returning web pages off disk (unless you provide event handling code). Complete control when building dynamic HTML content by setting properties of the Response object. Session, Request, and Response objects manage dynamic behavior and content. Program in your preferred development environment; just add your logic to respond to any request. Supports COM+ Component Services. Can be used in a multi-threaded environment. Includes a royalty-free license. Wrapper classes included for convenient integration into Visual C++. Features pullpage Code Examples pullpage Release History pullpage Online Documentation NT Service ActiveX Control NT Service ActiveX Control The NT Service control is used to turn any application into an NT Service. Features include: Easily turn any server applications built using PowerTCP products into services. Applications built with the Service Control target server-side applications that always run in the background, even when a user is not logged into the system. With the Service control you can respond to all service events, including Start, Stop, Pause, and Resume. The Message event is included to support user messages sent from external applications. The Log method is included for logging event messages. Convenient Install and Uninstall methods provide a way for your application to install and uninstall itself as a service. The Abort method allows your service to abort and stop itself while running. Interface Members Public Properties Params Contains the parameters passed to your service. This property may be read when the State property is serviceRunning. State Determine what state the service is in. The State event fires to signal that this property has changed. Public Methods Abort Abort and stop a running service. About Show the About Box. Connect Connect the service to the operating system’s Service Control Manager (SCM). Call this method as soon as possible after your application starts. Install Install the application as a service. Log Enter an event in the Windows Event Log. Uninstall Uninstall a service. Public Events Error Fires when an error occurs. This event fires before the error is reported back to the container's error object Message Fires when an application sends the service a user message. This can be used any way you wish, as it has no special meaning to the operating system. State Fires to indicate the State property has changed value. Code Example How easy is the NT Service control to use? Check out the following Service VB example below, which demonstrates creating an echo service with the Server control. Private Sub Form_Load() On Error GoTo OnError ' use intrinsic error handling 'Connect to the Service Control Manager Service1.Connect Exit SubOnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.DescriptionEnd SubPrivate Sub Service1_State() On Error GoTo OnError ' use intrinsic error handling Dim I As Integer Select Case Service1.State Case serviceRunning ' service is now running, beep to the world! Beep ' Start the Echo Server Server1.Listen 7 Case servicePaused ' service is now going to sleep, stop listening for new connections Server1.Close Case serviceResumed ' service is now waking up from sleep, resume listening! Server1.Listen 7 Case serviceStopped ' service is now stopping, log a message to Windows event log Service1.Log serviceInformation, serviceInfoEvent, “Stopping” ' stop listening for new connections Server1.Close ' shut down all active connections For I = 1 To Server1.Children.Count Server1.Children(I).Close Next End Select Exit SubOnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.DescriptionEnd Sub WebServer ActiveX Control (HTTP, HTTPS) WebServer ActiveX Control (HTTP, HTTPS) Use the WebServer control to turn any application into a custom HTTP Web Server. Build Web Applications in a familiar software environment. Features include: Allows you to create a server side web application without having to learn ASP, Cold Fusion or other web application development environment. Give a web interface to any stand-alone application. Compatible with MS SOAP library (create a SOAP server). Supports HTTPS. Development Environments Visual Studio .NET (.NET Framework) Visual Basic (VB) Visual C++ (VC++) FoxPro PowerBuilder Delphi C++ Builder Office 97/2000 Interface Public Constructors WebServer Build web-based applications from within Visual Basic or any other development environment that supports ActiveX controls. Public Properties Certificate Certificate Object to use when authenticating to the remote host. ClientAuthentication Applies to server operation only. Count Number of nonsecure TCP connections currently open. DefaultFiles Collection of default filenames. LocalAddress Returns the address in use while the Daemon is active and an empty string when the Daemon socket is closed. LocalPort Returns the port number in use while the Daemon is active and 0 when the Daemon is closed. LocalSecureAddress Returns the local host address being used for accepting secure connections. The format is dot notation (for example, nnn.nnn.nnn.nnn). A non-empty value indicates the WebServer Control is accepting secure HTTP requests. LocalSecurePort Returns the port number being used for accepting secure connections. A non-zero value indicates the WebServer Control is accepting secure HTTP requests. LogDirectory Directory for daily log files. The default value is an empty string. MaxIdleTime Amount of time a session can remain idle before expiring. MaxMemBuffer Maximum number of memory bytes used when receiving the body of a request. PlaceCookies Controls whether cookies are sent. Only affects the automatic Dart Cookies. Protocol Specifies the security protocol used. PutLength Controls whether the Content-Length is inserted in the header. RootDirectory Root directory for web pages. SecureCount Number of secure connections currently open. Sessions Collection of active Session Objects. UseTemp Gets or sets whether or not to place uploaded files in the temp directory. Public Methods About Show the About Box. Pause Stop the server from accepting new connections, while allowing established connections and sessions to persist. Start Start processing HTTP/HTTPS requests. Stop Stop the server from accepting new connections and immediately close existing client connections. Trace Start or stop the accumulation of trace or debug data. Once started, this method accumulates data until it is turned off. Public Events Authenticate Fires when the remote host has sent a certificate to be authenticated. Error Fires whenever an error condition occurs. Get Fires when a GET request is received. By default, file information and content is sent back to the client. Place code within this event to modify the default response. Head Fires when a HEAD request is received. By default, header information is sent back to the client. Place code within this event to modify the default response. Post Fires when a POST request is received. By default, a status of "Forbidden" is returned. Place code within this event to modify the default response. Put Fires when a PUT request is received. By default, a status of "Forbidden" is returned. Place code within this event to modify the default response. Request Fires when an unknown request is received. SessionEnd Fires before a session is destroyed. SessionInit Fires after a new session is created. Code Example How easy is the WebServer control to use? Check out the following VB example below, which demonstrates "starting" a webserver, then responding to an HTTP GET request (which causes the WebServer component's Get event to fire). Private Sub Command1_Click() On Error GoTo OnError ' use intrinsic error handling ' Start a non-secure server on port 8080 WebServer1.Start 8080, -1 Exit SubOnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.DescriptionEnd SubPrivate Sub WebServer1_Get(ByVal Session As DartWebServerCtl.ISession,_ ByVal Request As DartWebServerCtl.IRequest,_ ByVal Response As DartWebServerCtl.IResponse) On Error GoTo OnError ' use intrinsic error handling Response.Header(httpServer) = "My Web Server/1.0" ' Add other headers here. If Response.Status = httpOK Then ' found template page... Else ' page not found: return default error page End If Exit SubOnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.DescriptionEnd Sub