Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11594 > unrolled thread

MSWinSck.ocx - listen at localhost ?

Started by"R.Wieser" <address@not.available>
First post2017-04-04 11:59 +0200
Last post2017-04-04 22:35 +0200
Articles 5 — 3 participants

Back to article view | Back to microsoft.public.scripting.vbscript


Contents

  MSWinSck.ocx - listen at localhost ? "R.Wieser" <address@not.available> - 2017-04-04 11:59 +0200
    Re: MSWinSck.ocx - listen at localhost ? "R.Wieser" <address@not.available> - 2017-04-04 14:27 +0200
      Re: MSWinSck.ocx - listen at localhost ? "Mayayana" <mayayana@invalid.nospam> - 2017-04-04 09:48 -0400
      Re: MSWinSck.ocx - listen at localhost ? JJ <jj4public@vfemail.net> - 2017-04-04 23:43 +0700
        Re: MSWinSck.ocx - listen at localhost ? "R.Wieser" <address@not.available> - 2017-04-04 22:35 +0200

#11594 — MSWinSck.ocx - listen at localhost ?

From"R.Wieser" <address@not.available>
Date2017-04-04 11:59 +0200
SubjectMSWinSck.ocx - listen at localhost ?
Message-ID<58e36e5f$0$723$e4fe514c@news.xs4all.nl>
Hello All,

I'm trying to get MSWinSock to listen at 127.0.0.1, but am, in the
end,unsuccessfull in doing so.

That is, I'm able to create a listening socket at the indicated IP (if I may
believe netstat -a -n) by binding the socket before listening to it, but
pointing my webbrowser to it doesn't seem to generate any of the events --
though it keeps waiting for the connection until I abort the script (upto
the browser own timeout ofcourse).

Can anyone tell me what I'm supposed to add/change ?

The code:
- - - - - - - - - - - - - - - -
Set socket = WScript.CreateObject("MSWinsock.Winsock", "wsock_")
socket.Close()
call socket.Bind(8081,"127.0.0.1")
socket.Listen

while true
sleep(1000)
wend
....
sub wsock_ConnectionRequest(reqestid)
  socket.Close()
  MsgBox("Request received, socket closed")
end sub
- - - - - - - - - - - - - - - -

Regards,
Rudy Wieser

[toc] | [next] | [standalone]


#11595

From"R.Wieser" <address@not.available>
Date2017-04-04 14:27 +0200
Message-ID<58e39125$0$815$e4fe514c@news.xs4all.nl>
In reply to#11594
Update:

  The "sleep(1000)" there seems to be the problem: when I replace it with a
MsgBox the event pops up just nicely.

And to be honest: as the script is running on a Win98 machine (in which the
wscript object does not expose a sleep command) I hade to create that
"sleep" myself: its a thin wrapper around the kernel32.dll's Sleep function.
put into an OCX object.

Note to self: take a peek at how (for example) XPs vbscript build-in sleep
differs from Kernel32's Sleep. :-)

-- Don't you just hate it when the cause of a problem divulges itself just
minutes after having posted a question about it ?... :-( :-)

Regards,
Rudy Wieser

R.Wieser <address@not.available> schreef in berichtnieuws
58e36e5f$0$723$e4fe514c@news.xs4all.nl...
> Hello All,
>
> I'm trying to get MSWinSock to listen at 127.0.0.1, but am, in the
> end,unsuccessfull in doing so.
>
> That is, I'm able to create a listening socket at the indicated IP (if I
may
> believe netstat -a -n) by binding the socket before listening to it, but
> pointing my webbrowser to it doesn't seem to generate any of the events --
> though it keeps waiting for the connection until I abort the script (upto
> the browser own timeout ofcourse).
>
> Can anyone tell me what I'm supposed to add/change ?
>
> The code:
> - - - - - - - - - - - - - - - -
> Set socket = WScript.CreateObject("MSWinsock.Winsock", "wsock_")
> socket.Close()
> call socket.Bind(8081,"127.0.0.1")
> socket.Listen
>
> while true
> sleep(1000)
> wend
> ....
> sub wsock_ConnectionRequest(reqestid)
>   socket.Close()
>   MsgBox("Request received, socket closed")
> end sub
> - - - - - - - - - - - - - - - -
>
> Regards,
> Rudy Wieser
>
>

[toc] | [prev] | [next] | [standalone]


#11597

From"Mayayana" <mayayana@invalid.nospam>
Date2017-04-04 09:48 -0400
Message-ID<oc081r$2nb$1@dont-email.me>
In reply to#11595
"R.Wieser" <address@not.available> wrote

|  The "sleep(1000)" there seems to be the problem: when I replace it with a
| MsgBox the event pops up just nicely.
|
  For what it's worth... I would think it makes more
sense to site the control in an HTA. Then you don't
need Sleep.

  When I do need Sleep in an HTA or VBS where I
can't use Sleep, I use an external script function.
Sleeper.vbs contains this:

Dim Arg
  on error resume next
 Arg = WScript.Arguments(0)
 wscript.sleep Arg

The function to call it is like so:

Private Sub SleepX(MSecs) '--Function to cause A pause since WScript is Not 
available from webpage:
  Dim Ret1
    On Error Resume Next
    Ret1 = SHcc.Run("sleeper.vbs " & MSecs, , True)
End Sub

Calling the sub:   SleepX "500"

[toc] | [prev] | [next] | [standalone]


#11600

FromJJ <jj4public@vfemail.net>
Date2017-04-04 23:43 +0700
Message-ID<1cfo9jj8y3wa6.1onglabpfuvvy.dlg@40tude.net>
In reply to#11595
On Tue, 4 Apr 2017 14:27:41 +0200, R.Wieser wrote:
> Update:
> 
>   The "sleep(1000)" there seems to be the problem: when I replace it with a
> MsgBox the event pops up just nicely.
> 
> And to be honest: as the script is running on a Win98 machine (in which the
> wscript object does not expose a sleep command) I hade to create that
> "sleep" myself: its a thin wrapper around the kernel32.dll's Sleep function.
> put into an OCX object.

Perhaps you didn't realize that VBScript has the same limitation as JScript,
which is being single-threaded. Just like JavaScript.

> Note to self: take a peek at how (for example) XPs vbscript build-in sleep
> differs from Kernel32's Sleep. :-)

There's no SleepEx() at the time VBScript was designed, so VBScript's Sleep
is not alertable/interruptable.

[toc] | [prev] | [next] | [standalone]


#11607

From"R.Wieser" <address@not.available>
Date2017-04-04 22:35 +0200
Message-ID<58e4038c$0$815$e4fe514c@news.xs4all.nl>
In reply to#11600
JJ,

> Perhaps you didn't realize that VBScript has the same limitation as
> JScript, which is being single-threaded.

On de contrary, I was/am quite aware of that.

> so VBScript's Sleep is not alertable/interruptable.

Than we've got at least two problems:

#1: I've seen several examples using "wscript.sleep(...)" in a never-ending
loop (hence me trying the same).   You mean to say that all of those are
rubbish ?

#2: A modal message-box (as VBScript has them) also halts a single-threaded
program.

Nope, I get the feeling that both of the above to a bit more than meets the
eye. :-)

Regards,
Rudy Wieser


-- Origional message:
JJ <jj4public@vfemail.net> schreef in berichtnieuws
1cfo9jj8y3wa6.1onglabpfuvvy.dlg@40tude.net...
> On Tue, 4 Apr 2017 14:27:41 +0200, R.Wieser wrote:
> > Update:
> >
> >   The "sleep(1000)" there seems to be the problem: when I replace it
with a
> > MsgBox the event pops up just nicely.
> >
> > And to be honest: as the script is running on a Win98 machine (in which
the
> > wscript object does not expose a sleep command) I hade to create that
> > "sleep" myself: its a thin wrapper around the kernel32.dll's Sleep
function.
> > put into an OCX object.
>
> Perhaps you didn't realize that VBScript has the same limitation as
JScript,
> which is being single-threaded. Just like JavaScript.
>
> > Note to self: take a peek at how (for example) XPs vbscript build-in
sleep
> > differs from Kernel32's Sleep. :-)
>
> There's no SleepEx() at the time VBScript was designed, so VBScript's
Sleep
> is not alertable/interruptable.

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.scripting.vbscript


csiph-web