DSAPI Multi-functional component programming application-http Monitoring Server and client _ instruction version

Source: Internet
Author: User

The DSAPI multi-functional component programming application-http Monitoring Server and client content is described here, and here is an application for more efficient and faster HTTP listener-based server, client.

In this article, you will see unprecedented ultra-simplified ultra-stupid HTTP listening service, unlike in the previous article, in Dsapi, the instruction version contains both the server and the client.

Take a look at the use of the method, almost do not need a lot of instructions, of course, it is to support the event. The so-called instruction version, that is, the server and the client send and receive are based on short strings, such as the client sends a "Hello", the server received this command after the return of a "Hi." To ensure the data validity of the transfer, the default is to use Base64 to encrypt the transfer, and the property is hidden in the instruction version because the user cannot use this property.

Set up a command version of HTTP snooping

Private WithEvents service-side as New DSAPI. Network-related. HTTP listener instruction version   with server            . Bind port = 2000 ' bound port            . Parameter leader = True  ' If parameter leader is used, The meaning is the same as in the previous article            . Allow extranet connections = True to allow extranet requests            . Start monitoring ()        End with

Just a few lines of code, the completion of an HTTP listener-based command version of the service side, the following events are supported:

    Private Sub Server _ Listener started () Handles server. The listener has started end    Sub    Private Sub service Side _ Listener stopped () Handles server. Listen stopped    End Sub    Private Sub-Server _ receives the instruction (client as DSAPI. Network-related. HTTP listening instruction version. Listen to the client instruction version, instruction content as String) Handles the server. Received instruction end    Sub    Private Sub Service Side _ encountered error (Error as Exception) Handles server. Encountered error    end Sub

processing the received instruction

The Private Sub Service side _ Receives the instruction (client as DSAPI. Network-related. HTTP listening instruction version. Listen to the client-instruction version, instruction content as String) Handles the server. Receive instruction        Select case Directive content            C ASE "Hello" server                . Writes information to the specified client output stream (client, "hello,my friend") Case            "get" server                . Writes information to the specified client output stream (client, IO. File.readallbytes ("C:\1.rar")) Case            Else                Server. Write information to the specified client output stream (client, "No")        End Select    End Sub

The sent instruction content is provided directly in the parameter so that the Select Case, again, is returned to the client, can be text, or it can be a byte array, such as a file.

The establishment and use of the server is the above, the following shows how to establish a command version of the client.


A directive version of HTTP listener client is recommended

Private WithEvents Client as New DSAPI. Network-related. HTTP Listener _ command version. Listen to the client-instruction version with  client            . Timeout = 1000 ' custom timeout            . Server-side IP or domain name = "127 .0.0.1 "            . Server port number = End With        

It's that simple, okay, now look at how to use the client to send a command to the server and get the return data.


MsgBox (client. Get Data ("Hello"))

A code, what? That's it? Yes, you're right, it's so simple. This is what I call the command version, I believe you will like it.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

DSAPI Multi-functional component programming application-http Monitoring Server and client _ instruction version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.