Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11599 > unrolled thread
| Started by | "R.Wieser" <address@not.available> |
|---|---|
| First post | 2017-04-04 18:37 +0200 |
| Last post | 2017-04-14 09:12 +0200 |
| Articles | 13 — 4 participants |
Back to article view | Back to microsoft.public.scripting.vbscript
MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-04 18:37 +0200
Re: MSWinsock.ocx - server: handle more than a single connection & share events "Mayayana" <mayayana@invalid.nospam> - 2017-04-04 13:34 -0400
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-04 22:49 +0200
Re: MSWinsock.ocx - server: handle more than a single connection & share events "Mayayana" <mayayana@invalid.nospam> - 2017-04-04 17:00 -0400
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-05 09:52 +0200
Re: MSWinsock.ocx - server: handle more than a single connection & share events "Mayayana" <mayayana@invalid.nospam> - 2017-04-05 15:32 -0400
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-06 10:15 +0200
Re: MSWinsock.ocx - server: handle more than a single connection & share events "Mayayana" <mayayana@invalid.nospam> - 2017-04-06 09:42 -0400
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-06 17:47 +0200
Re: MSWinsock.ocx - server: handle more than a single connection & share events JJ <jj4public@vfemail.net> - 2017-04-05 00:42 +0700
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-04 23:03 +0200
RE: MSWinsock.ocx - server: handle more than a single connection & share events Mr. E < meme@me.com> - 2017-04-14 04:55 +0000
Re: MSWinsock.ocx - server: handle more than a single connection & share events "R.Wieser" <address@not.available> - 2017-04-14 09:12 +0200
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-04 18:37 +0200 |
| Subject | MSWinsock.ocx - server: handle more than a single connection & share events |
| Message-ID | <58e3cbbe$0$739$e4fe514c@news.xs4all.nl> |
Hello all, After having figured out my previous problem (not getting events) I almost directly bumped into another one: Imagine a simple HTTP server, which should be able to handle several requests at a time. Almost directly a few problems pop-up. Googeling for 1) How do I get a single listening socket to "spawn" multiple data sockets -- the standard method of closing the listening socket down and than accepting the new connection on the now-free socket would, AFAICS, cause other waiting connection-requests to be dropped. Which is double-plus non-good. 2) How do I get to share the events for the different data-sockets ? -- Although MSDN* tells me that the MSWinsock control should be able to work as/in a "control array" and the connectionRequest event supposedly has an "index" argument, looking at the typelib exposed by the MSWinsck.ocx control** I have here I can't discover the first (no index property) nor the second (the connectionRequest event shows it has only got a single argument (supposedly the connectionID) ) * https://msdn.microsoft.com/en-us/library/aa733709(v=vs.60).aspx ** v6.0 SP5. TL;DR: Does someone have an example handy which shows the basics of a multi-connection MSWinsock server for a Win98se environment ? I could surely use one -- if only to figure out how the different parts play together. Regards, Rudy Wieser
[toc] | [next] | [standalone]
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Date | 2017-04-04 13:34 -0400 |
| Message-ID | <oc0l9v$jd0$1@dont-email.me> |
| In reply to | #11599 |
"R.Wieser" <address@not.available> wrote | | TL;DR: Does someone have an example handy which shows the basics of a | multi-connection MSWinsock server for a Win98se environment ? I could | surely use one -- if only to figure out how the different parts play | together. I can't imagine what you're planning in trying to set up a multiple port server through a VBScript. In any case, that's a VB6 control. The indexing is in the VB6 environment. In other words, plop 3 of them on a VB6 form with the same name and VB will make them an array. VBScript is not going to do that. It's not part of the control functionality. I use VB6 a lot but have never used the Winsock control. I just use Windows sockets directly. I have a free http ActiveX EXE, but I'm not sure it will do what you want: http://www.jsware.net/jsware/compfiles.php5#jshttp It's not a winsock wrapper. It handles the dirty work to do specific things, like downloading files.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-04 22:49 +0200 |
| Message-ID | <58e406b4$0$733$e4fe514c@news.xs4all.nl> |
| In reply to | #11602 |
Mayayana, The indexing is in the VB6 environment. > In other words, plop 3 of them on a VB6 form with the > same name and VB will make them an array Understood. That makes everything even harder, as in plain VBS/wscript none of the WinSock events than carry any indication to which object fired them ... And odd: Why does the ConnectionRequest event deliver a "requestID" which than needs to be used with the accept method. I mean, there is-and-can-be only a single socket for any existing WinSock object, so why than that, as far as I can tell, rather superfluous ID ? > I have a free http ActiveX EXE, but I'm not sure it will do > what you want: Thanks, but if I can't get that MSWinSock object to do what I want I might have some fun in writing one myself. :-) Regards, Rudy Wieser Mayayana <mayayana@invalid.nospam> schreef in berichtnieuws oc0l9v$jd0$1@dont-email.me... > "R.Wieser" <address@not.available> wrote > > | > | TL;DR: Does someone have an example handy which shows the basics of a > | multi-connection MSWinsock server for a Win98se environment ? I could > | surely use one -- if only to figure out how the different parts play > | together. > > I can't imagine what you're planning in trying to set > up a multiple port server through a VBScript. In any case, > that's a VB6 control. The indexing is in the VB6 environment. > In other words, plop 3 of them on a VB6 form with the same > name and VB will make them an array. VBScript is not > going to do that. It's not part of the control functionality. > > I use VB6 a lot but have never used the Winsock > control. I just use Windows sockets directly. I have a > free http ActiveX EXE, but I'm not sure it will do what > you want: > > http://www.jsware.net/jsware/compfiles.php5#jshttp > > It's not a winsock wrapper. It handles the dirty work > to do specific things, like downloading files. > >
[toc] | [prev] | [next] | [standalone]
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Date | 2017-04-04 17:00 -0400 |
| Message-ID | <oc11cm$2kq$1@dont-email.me> |
| In reply to | #11608 |
"R.Wieser" <address@not.available> wrote
| > I have a free http ActiveX EXE, but I'm not sure it will do
| > what you want:
|
| Thanks, but if I can't get that MSWinSock object to do what I want I might
| have some fun in writing one myself. :-)
|
In that case you could internalize indexing
and anything else you like. I find the problem
of stasis in VBS very awkward. One has to keep
doing *something*. I chose to get around that
by having a Busy property in my AxEXE. So
I don't need anything like Sleep. I just do something
like
Obj.DownloadFile URL
While Obj.Busy = True
Wend
The control then sends the event and sets Busy
false when the download is ready.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-05 09:52 +0200 |
| Message-ID | <58e4a21b$0$745$e4fe514c@news.xs4all.nl> |
| In reply to | #11609 |
Mayayana,
> In that case you could internalize indexing
> and anything else you like.
In that case I would not even use an index. I would than not have the
object return a socket (like MSWinSck does), but just behave as an
entry-point for whatever I further want to do, exposing methods like
"connect" and "listen" commands which return "socket" objects. :-) (but
although the "sockets" could be put into a user-defined array or dictionary
object and handled that way, I would most likely include an enumeration
method for them)
> I find the problem of stasis in VBS very awkward. One has to keep
> doing *something*.
True. But thats a drawback/shortcoming of both W- and CScript.exe. When
you put a scripting engine into a program of your own you can hold-off the
actual closing of the engine itself for as long as you want, allowing you to
still do call-backs into the script.
But yes, I've also been thinking about the same. For example, I've created
a small "logging window" OCX, which I use to "print" to when I run a script
in GUI mode (using WScript), as I got fed up with either not knowing what
was going on, or have a steady stream of "must click to dismiss" msgbox
alerts. I would really like to be able to have, in the end, the script wait
for the "logging window" to be closed (by the user) before actually
terminating.
And as stuff goes, I just realized that possiby wanting to keep "events"
running makes that even harder to accomplish. :-\ :-)
> I chose to get around that by having a Busy property in
> my AxEXE. So I don't need anything like Sleep.
And that tight loop still allows events to be handled ? Remarkable.
My own attempt to create an all-script "sleep" is the below. Alas, it
didn't work (in regard to events).
- - - - - - - - - - - - - - - -
sub WaitSome(seconds)
dim dummy
for i=0 to seconds
dummy=second(now)
while dummy=second(now)
wend
next
end sub
- - - - - - - - - - - - - - - -
Mind you, the delay works works well enough in itself.
Regards
Rudy Wieser
-- Origional message
Mayayana <mayayana@invalid.nospam> schreef in berichtnieuws
oc11cm$2kq$1@dont-email.me...
> "R.Wieser" <address@not.available> wrote
>
> | > I have a free http ActiveX EXE, but I'm not sure it will do
> | > what you want:
> |
> | Thanks, but if I can't get that MSWinSock object to do what I want I
might
> | have some fun in writing one myself. :-)
> |
> In that case you could internalize indexing
> and anything else you like. I find the problem
> of stasis in VBS very awkward. One has to keep
> doing *something*. I chose to get around that
> by having a Busy property in my AxEXE. So
> I don't need anything like Sleep. I just do something
> like
>
> Obj.DownloadFile URL
> While Obj.Busy = True
> Wend
>
> The control then sends the event and sets Busy
> false when the download is ready.
[toc] | [prev] | [next] | [standalone]
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Date | 2017-04-05 15:32 -0400 |
| Message-ID | <oc3giq$p0r$1@dont-email.me> |
| In reply to | #11611 |
"R.Wieser" <address@not.available> wrote | > I chose to get around that by having a Busy property in | > my AxEXE. So I don't need anything like Sleep. | | And that tight loop still allows events to be handled ? | Yes. Because it's tight. While Obj.Busy = True Wend That leaves it checking constantly. When my component makes a file request via winsock it makes it through a winsock userControl. If that request is OK it sets Busy = True. The winsock UC then sends an event when the file is finished downloaded. With that event the component raises the event for the scriot, OnDownloadFinish, and then sets Busy = False. It gets complicated, but doing things in that order seems to work.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-06 10:15 +0200 |
| Message-ID | <58e5f913$0$707$e4fe514c@news.xs4all.nl> |
| In reply to | #11612 |
Mayayana, > When my component makes a file request via winsock it > makes it through a winsock userControl. If that request is > OK it sets Busy = True. Ah, thataway. I was stuck thinking about a generic "just wait" loop, and just didn't recognise/realize that it was a "do you need to do something ?" check. :-\ Yep, that works. And as it doesn't even actually sleep you can even stack a number of those checks for multiple incarnations of objects using the same method. One drawback though: that method will most likely keep your processor running at 100% ... And I was thinking of why you could not simply use a blocking call like "select", but realized that your method allows for multiple objects/sockets to be active-and-checked at the same time. Regards, Rudy wieser. -- Origional message: Mayayana <mayayana@invalid.nospam> schreef in berichtnieuws oc3giq$p0r$1@dont-email.me... > "R.Wieser" <address@not.available> wrote > > | > I chose to get around that by having a Busy property in > | > my AxEXE. So I don't need anything like Sleep. > | > | And that tight loop still allows events to be handled ? > | > Yes. Because it's tight. > > While Obj.Busy = True > Wend > > That leaves it checking constantly. When my component > makes a file request via winsock it makes it through a > winsock userControl. If that request is OK it sets Busy = True. > The winsock UC then sends an event when the file is > finished downloaded. With that event the component > raises the event for the scriot, OnDownloadFinish, and > then sets Busy = False. > > It gets complicated, but doing things in that order > seems to work. > >
[toc] | [prev] | [next] | [standalone]
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Date | 2017-04-06 09:42 -0400 |
| Message-ID | <oc5gff$mpi$1@dont-email.me> |
| In reply to | #11613 |
"R.Wieser" <address@not.available> wrote | One drawback though: that method will most likely keep your processor | running at 100% ... | Interesting point. That seems true, but it doesn't seem to work that way. All compiled software is basically running a loop to keep going. And there's no freezeup. I don't know how it works technically. I'd guess that maybe the process just forfeits its CPU timeslice each time it comes around, so that no CPU load is recorded. That would explain how 20 processes can be loaded but not using resources. They're all prepared to respond in the next microsecond that they're offered a timeslice, but they pass on the offer. Like a bottle of wine being passed endlessly around at an AA meeting. The wine is never dissipated but is always available in short order if anyone decides to drink.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-06 17:47 +0200 |
| Message-ID | <58e662f9$0$764$e4fe514c@news.xs4all.nl> |
| In reply to | #11614 |
Mayayana, > Interesting point. That seems true, but it doesn't > seem to work that way. ... > I'd guess that maybe the process just forfeits its > CPU timeslice each time it comes around, :-) I did not think about other programs/tasks. But yes, than the time-slice manager will make sure that other programs get some time to run too. And by the way, this afternoon I tried to take a peek in wscripts "sleep" method. It seems to do one-second sleeps and calls other stuff in between. I imagine that it could be doing VBScripts version of short sleeps and "do events" calls. > Like a bottle of wine being passed endlessly > around at an AA meeting. The wine is never dissipated > but is always available in short order if anyone decides > to drink. Can I have one of those bottles please ? :-) Regards, Rudy Wieser -- Origional message: Mayayana <mayayana@invalid.nospam> schreef in berichtnieuws oc5gff$mpi$1@dont-email.me... > "R.Wieser" <address@not.available> wrote > > | One drawback though: that method will most likely keep your processor > | running at 100% ... > > Interesting point. That seems true, but it doesn't > seem to work that way. All compiled software is > basically running a loop to keep going. And there's > no freezeup. > > I don't know how it works technically. > > I'd guess that maybe the process just forfeits its > CPU timeslice each time it comes around, so that > no CPU load is recorded. That would explain how > 20 processes can be loaded but not using resources. > They're all prepared to respond in the next microsecond > that they're offered a timeslice, but they pass on the > offer. Like a bottle of wine being passed endlessly > around at an AA meeting. The wine is never dissipated > but is always available in short order if anyone decides > to drink. > >
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2017-04-05 00:42 +0700 |
| Message-ID | <wexn8pw0wl1x$.1a1pz13s6lcjc.dlg@40tude.net> |
| In reply to | #11599 |
On Tue, 4 Apr 2017 18:37:40 +0200, R.Wieser wrote: > Hello all, > > After having figured out my previous problem (not getting events) I almost > directly bumped into another one: Imagine a simple HTTP server, which > should be able to handle several requests at a time. Almost directly a few > problems pop-up. Googeling for > > 1) How do I get a single listening socket to "spawn" multiple data > sockets -- the standard method of closing the listening socket down and than > accepting the new connection on the now-free socket would, AFAICS, cause > other waiting connection-requests to be dropped. Which is double-plus > non-good. Accept the connection, but do further processing on it at later time using a timer. The important thing is to let the VBScript enters the idle state so that any pending connection events can be passed to the VBScript by the Winsock OCX. > 2) How do I get to share the events for the different data-sockets ? -- > Although MSDN* tells me that the MSWinsock control should be able to work > as/in a "control array" and the connectionRequest event supposedly has an > "index" argument, looking at the typelib exposed by the MSWinsck.ocx > control** I have here I can't discover the first (no index property) nor the > second (the connectionRequest event shows it has only got a single argument > (supposedly the connectionID) ) > > * https://msdn.microsoft.com/en-us/library/aa733709(v=vs.60).aspx > > ** v6.0 SP5. > > TL;DR: Does someone have an example handy which shows the basics of a > multi-connection MSWinsock server for a Win98se environment ? I could > surely use one -- if only to figure out how the different parts play > together. Type Library is only for a reference for applications which don't know what members are available in a COM interface, or need to know what interface and their members are available. It's not really a requirement. Any COM/ActiveX can be fully functional even if it doesn't have embedded or external Type Library. COM/ActiveX modules are the one that validate whether an interface member name is available or not, not the application that use them. Just follow example code in that page and treat the control as if it's an array of objects. See below page if you're still confused. <http://www.devx.com/tips/Tip/5488>
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-04 23:03 +0200 |
| Message-ID | <58e40a25$0$824$e4fe514c@news.xs4all.nl> |
| In reply to | #11603 |
JJ, > The important thing is to let the VBScript enters the idle state so > that any pending connection events can be passed to the VBScript > by the Winsock OCX. That won't work, as I have no control over when a connection request comes in. Furthermore, the response the vbscript server returns might provoke another request ... And as Mayayana just made clear to me (no "control array" in vbscript), I *can't* accept more than a single connection, as I've got only a single object (read: socket) available to run the "accept" method against ... (or that "requestID" must be usable by other incarnations ofthe same object, but I doubt that). > Type Library is ... not really a requirement. I know. But as its the only documentation available for the object, its what I have to work with. > Just follow example code in that page and treat the control as > if it's an array of objects. See below page if you're still confused. This time its you who is confused I'm afraid: I'm using VBScript (as per this newsgroups name), not Visual Basic. :-) Regards, Rudy Wieser -- Origional message: JJ <jj4public@vfemail.net> schreef in berichtnieuws wexn8pw0wl1x$.1a1pz13s6lcjc.dlg@40tude.net... > On Tue, 4 Apr 2017 18:37:40 +0200, R.Wieser wrote: > > Hello all, > > > > After having figured out my previous problem (not getting events) I almost > > directly bumped into another one: Imagine a simple HTTP server, which > > should be able to handle several requests at a time. Almost directly a few > > problems pop-up. Googeling for > > > > 1) How do I get a single listening socket to "spawn" multiple data > > sockets -- the standard method of closing the listening socket down and than > > accepting the new connection on the now-free socket would, AFAICS, cause > > other waiting connection-requests to be dropped. Which is double-plus > > non-good. > > Accept the connection, but do further processing on it at later time using a > timer. The important thing is to let the VBScript enters the idle state so > that any pending connection events can be passed to the VBScript by the > Winsock OCX. > > > 2) How do I get to share the events for the different data-sockets ? -- > > Although MSDN* tells me that the MSWinsock control should be able to work > > as/in a "control array" and the connectionRequest event supposedly has an > > "index" argument, looking at the typelib exposed by the MSWinsck.ocx > > control** I have here I can't discover the first (no index property) nor the > > second (the connectionRequest event shows it has only got a single argument > > (supposedly the connectionID) ) > > > > * https://msdn.microsoft.com/en-us/library/aa733709(v=vs.60).aspx > > > > ** v6.0 SP5. > > > > TL;DR: Does someone have an example handy which shows the basics of a > > multi-connection MSWinsock server for a Win98se environment ? I could > > surely use one -- if only to figure out how the different parts play > > together. > > Type Library is only for a reference for applications which don't know what > members are available in a COM interface, or need to know what interface and > their members are available. It's not really a requirement. Any COM/ActiveX > can be fully functional even if it doesn't have embedded or external Type > Library. COM/ActiveX modules are the one that validate whether an interface > member name is available or not, not the application that use them. > > Just follow example code in that page and treat the control as if it's an > array of objects. See below page if you're still confused. > > <http://www.devx.com/tips/Tip/5488>
[toc] | [prev] | [next] | [standalone]
| From | Mr. E < meme@me.com> |
|---|---|
| Date | 2017-04-14 04:55 +0000 |
| Message-ID | <LCYHA.1238$0P5.650@fx31.iad> |
| In reply to | #11599 |
On Tue Apr 4 18:37:40 2017 "R.Wieser" wrote: > Hello all, > > After having figured out my previous problem (not getting events) I almost > directly bumped into another one: Imagine a simple HTTP server, which > should be able to handle several requests at a time. Almost directly a few > problems pop-up. Googeling for >... > TL;DR: Does someone have an example handy which shows the basics of a > multi-connection MSWinsock server for a Win98se environment ? I could > surely use one -- if only to figure out how the different parts play > together. After a similar fight with MSWinsock a few years ago I moved to SocketWrench. Version 6.0 is free unlimited time for personal use. I have use it under XP, win 7 and 10. I use it for a basic HTTP and file server as well as web based control of some home automation. (Web <-> pc <-> Bluetooth lights and security etc.) NOTE: It to use SocketWrench 6.0 with VBS it seems you need to have some version of visual basic installed for some MS license?? (community version is ok) My code is pure VBS not VB, the install is ONLY for the license. Mr. E --- This email has been checked for viruses by AVG. http://www.avg.com
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2017-04-14 09:12 +0200 |
| Message-ID | <58f07649$0$797$e4fe514c@news.xs4all.nl> |
| In reply to | #11616 |
Mr. E, > After a similar fight with MSWinsock a few years ago I moved > to SocketWrench. I take from that you where (also) unsuccessfull in finding a working solution. Its not so much that I need another socket object*, but am seriously wondering if either I am/where missing some info to make it work, or that the MSWinSock component is (rater intentionally if you ask me) crippeled to allow only a single connection at any time. *have been tinkering in that direction myself. :-) An extra problem and a show-stopper to me: to accept a connection means you have to switch off listening mode, dropping all other posibly present requests and stay "deaf" for the duration of handling the accepted connection. That won't work when the HTML page contains *any* kind of resource that also needs to be retrieved. On the other hand, it could not hurt to take a peek at that "socketwrench" object ... Regards, Rudy Wieser P.s. "This email has been checked for viruses by AVG." Thats fine-and-dandy, but how many did it find ? :-p -- Origional message: Mr. E < meme@me.com> schreef in berichtnieuws LCYHA.1238$0P5.650@fx31.iad... On Tue Apr 4 18:37:40 2017 "R.Wieser" wrote: > Hello all, > > After having figured out my previous problem (not getting events) I almost > directly bumped into another one: Imagine a simple HTTP server, which > should be able to handle several requests at a time. Almost directly a few > problems pop-up. Googeling for >... > TL;DR: Does someone have an example handy which shows the basics of a > multi-connection MSWinsock server for a Win98se environment ? I could > surely use one -- if only to figure out how the different parts play > together. After a similar fight with MSWinsock a few years ago I moved to SocketWrench. Version 6.0 is free unlimited time for personal use. I have use it under XP, win 7 and 10. I use it for a basic HTTP and file server as well as web based control of some home automation. (Web <-> pc <-> Bluetooth lights and security etc.) NOTE: It to use SocketWrench 6.0 with VBS it seems you need to have some version of visual basic installed for some MS license?? (community version is ok) My code is pure VBS not VB, the install is ONLY for the license. Mr. E --- This email has been checked for viruses by AVG. http://www.avg.com
[toc] | [prev] | [standalone]
Back to top | Article view | microsoft.public.scripting.vbscript
csiph-web