Discussion:
MSWinSck.ocx - listen at localhost ?
(too old to reply)
R.Wieser
2017-04-04 09:59:16 UTC
Permalink
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
R.Wieser
2017-04-04 12:27:41 UTC
Permalink
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
Post by R.Wieser
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 ?
- - - - - - - - - - - - - - - -
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
Mayayana
2017-04-04 13:48:06 UTC
Permalink
This post might be inappropriate. Click to display it.
JJ
2017-04-04 16:43:00 UTC
Permalink
Post by R.Wieser
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.
Post by R.Wieser
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.
R.Wieser
2017-04-04 20:35:49 UTC
Permalink
JJ,
Post by 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.
Post by JJ
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
Post by JJ
Post by R.Wieser
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.
Post by R.Wieser
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.
Loading...