Re: VB6 Winsock action on Server




"jerry_ys" <jerryys@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:5107B4E6-5E19-43AA-BBCE-6C31E01E8ECB@xxxxxxxxxxxxxxxx

...
my usage of server app I meant the app on the server
that uses the control array and it then calls a dll for further
processing on the same server. It is this piece 'dll' that i
question if it will keep each request on the control array
in sync when it returns a response back to the calling exe
on the server.
Easiest way is, to delegate each request to a separate instance
of your 'dll' (assuming it is an ActiveX-Dll? - a Standard-Dll
could be wrapped in an AX-Dll).
Each separate "Winsock-Array-Requesthandler" should delegate
the recieved "JobData" to this unique instance of your Dll(-Class).
Ok, as long as you stay singlethreaded, it would be possible, to
use only one instance of this Dll (if there's only one single Method,
wich would be called in each request and the Dll-Design is really
stateless).
But if you plan, to handle multiple client-requests "in parallel", then
forget about this "single-instance-sharing" and give each request its
own Dll-Instance (ideally running on its own thread).

Also the server app with the control array assumes that many
clients are being processed simultaneously
is there any settings for the active exe, or dll for threading?
It's your choice, wich way to go, regarding multithreading in VB.
Easiest way is, to use an ActiveX-Exe - inside it, you can use the
CreateObject-Call, to instantiate Public AX-Exe-Classes on their
own threads. Inside each of these "ThreadObjects" you can create
separate "WorkHorse-Instances" of your above mentioned 'dll'.
Here my 10 step "Mini-Tutorial" for Threading in AX-Exes:
http://tinyurl.com/rvhjo

Another possibility is, to do CreateThread-based Threading using
Standard-Exes - here you could instantiate Public classes from your
Worker-'dll' directly on new threads and delegate the received
"Jobs" from the SocketArray into the Threads using SharedArrays.
An example, how to use the CreatThreadAPI in a secure way:
(including a SharedArray-Demo and the usage of CriticalSections)
www.datenhaus.de/Downloads/CreateThreadAPI.zip

Will there be a difference if the dll is first with the control
array instead of the active exe and it calls the active exe?
The overhead from the additional "Public-Class-Layer" in an AX-Exe
is not so big - I personally prefer the CreateThread-API solution
in VB-Standard-Exes, because of its "NoSurprises"-behaviour.

ActiveX-Exes have to be registered (sometimes causes problems,
especially if your Public-Classes aren't "interface-stable" yet) and
care must be taken, to avoid blocking issues with the marshaled
(and implicitely queued) COM-Requests into the ThreadClasses.

One word about the Winsock-OCX in Threading-Scenarios:
You cannot accept WinSockOCX-Instances on different threads
using the RequestID from the listening socket in the MainThread.
If you want to send the Response-Data of your processed Jobs
back to your Clients directly from *inside* the WorkerThreads,
you will have to deal with the Winsock-API directly.

If you then (after a while) got simple "Reflection-Requests" (usually
based on Strings) running in a small Stress-Test in parallel from
different Clients, then you probably think about a more generic
Handling, wich allows "Remote-Request-Params + Results" in a
generic way, with all the possible, wellknown (simple) VB-Types.
After you have implemented that, and managed, to run the whole
thing as a Windows-Service, you probably ask about running the
requests from different Clients in different Contexts (authenticated
DB-Requests - Filesystem-Access, etc. come to mind) and not
under the Context, your Windows-Service is currently running.
Then you could ask about compressing your Request-Results (e.g.
serialized disconnected Recordsets can get quite large) or you want
to use your Server from outside (over the Internet) and you begin to
think about authenticated and encrypted Requests.

Now, if you want to shorten your developement - you could use an
already existing solution, wich is free (you are allowed to deploy all
the needed binaries with no restrictions).
Over the last years we have managed all the issues described above
and ended up in exactly the solution, wich you are about to program
yourself.
It is implemented based on VB6 and allows the usage of VB5/VB6
COM-Dlls across Network-Boundaries:
www.datenhaus.de/Downloads/dh_RPC.zip
(Complete with a well-commented Demo).

The features in short:
- No Interface-Registration needed - respective no COM-Proxies
(neither at the ClientSide, nor at the ServerSide)
- Win-Authentication (and Impersonation of RPCs)
at Connection-Level
- Built-In Compression (ZLib-based)
- Built-In Strong-Encryption (320 Bit ArcFour and
MITM-safed Diffie-Hellman-Auth/KeyExchange)
- Stateful Objects (Singleton-Creation on separate Threads)
- Solid performance: e.g. 3000 COM-Req/s from 6 different
Client-Machines (500 Req/s on each single Connection),
generating 55% ProcessorLoad on a DualAthlon (2GHz).

Of course you could also use the already builtin services, wich the
WinOS already has to offer - the usage of DCOM/COM+ would
allow you a (more or less) similar solution, but this would require
(from my experience) a greater learning-effort, to master/workaround
all the usual snares.

Olaf


.



Relevant Pages

  • RE: process starvation with 2.6 scheduler
    ... The network traffic is of request response type. ... The netperf clients run on an external box, ... A client sends request to a server, ... With an ICE connected to the Palladium (emulator) I have dumped the kernel data structures of the starved process and the active process. ...
    (Linux-Kernel)
  • Re: Instances in DCOM
    ... You can create an out-of-proc server and set up its class ... start a process for each object created by your clients. ... > only one instance of your other DLL too - in the same DllHost ... > Microsoft MVP, MCSD ...
    (microsoft.public.win32.programmer.ole)
  • Re: Millions of Threads ?
    ... phones as clients. ... Of course, I need a server, too. ... turn-around time of 0.5 seconds, that suggests that you would have an average ... Notice that, on the above assumptions, you will be serving a request at ...
    (comp.lang.java.programmer)
  • Re: HTTP tunneling and Servlet communication
    ... almost definitely be behind a firewall/using a proxy server. ... I have come up with a class which acts as a Facade to clients and presents a course simpler request/response API to clients. ... I am not sure how to convert my method call into an HTTP request. ... Can I send request/responses AND data on the same tunnel?. ...
    (comp.lang.java.programmer)
  • Re: Instances in DCOM
    ... if it run as server side (in the same server that is installed the SQL ... But if in case of use a DLL we use a EXE, ... start a process for each object created by your clients. ...
    (microsoft.public.win32.programmer.ole)