2

I want to connect to a java server socket threw ASP Classic. For this when I google then found winsock.dll but it does not work. I try below code to create object

Dim x 
Set x = CreateObject("MSWINSOCK.Winsock.1")

but error comes cant create object . So can any body tell me how can I connect to a socket at a specific port threw vbscript. Is there any other com object provided by microsoft so that we can trust on that and use that.

agarwal_achhnera
  • 2,582
  • 9
  • 55
  • 84
  • 3
    Possible duplicate of [VBScript/JScript Networking: Connect either UDP or TCP](http://stackoverflow.com/questions/6348907/vbscript-jscript-networking-connect-either-udp-or-tcp). Addendum to the answer provided there: there are also free 3rd-party controls providing TCP/UDP socket functionality, e.g. w3sockets from [Dimac](http://www.dimac.net/default3.asp?M=FreeDownloads/Menu.asp&P=FreeDownloads/FreeDownloadsstart.asp). – Ansgar Wiechers Oct 03 '13 at 09:21

1 Answers1

4

The MSWINSOCK component is not provided by winsock.dll, it is provided by MSWinsck.ocx.

You can check it is registered by looking in RegEdit.exe under HKEY_CLASSES_ROOT\MSWinsock.Winsock.

This control is 32-bit only, so it will only work when running scripts with the 32-bit hosts.

I suspect you either don't have it installed, or are running your script under 64 bit operating system.

If the latter, you should launch your scripts from the 32bit hosts like so:

c:\windows\syswow64\cscript.exe //nologo c:\path\to\script.wsf /argument:value 

or:

c:\windows\syswow64\wscript.exe //nologo c:\path\to\script.wsf /argument:value 

But really I would suggest you should not be attempting general network communications application from VBScript. Try VB.Net instead.

Ben
  • 34,935
  • 6
  • 74
  • 113
  • Hi I am using 32 bit windows server 2003, and I search MSwinsock.Winsock in registry, but it does not exist. I am doing this by asp classic on web. could you please guide me how can I send request to a socket and receive message from there in asp classic for windows server systems for both 32 bit and 64 bit – agarwal_achhnera Oct 03 '13 at 08:48
  • 1
    It also does not ship with Windows Server 2003. If you have Visual Basic 6 it is part of the redistributable pack though. – Ben Oct 03 '13 at 09:09
  • My recommendation would be to create a DCOM server to do the job, and call the DCOM server from the ASP Classic page. You can use VB.Net or C# to create a DCOM executable server. – Ben Oct 03 '13 at 09:10
  • It can be possibly installed with http://support.microsoft.com/kb/974899 (Mswinsck.ocx 6.1.98.17 126,800 25-Sep-2009 01:32) – Roman R. Oct 03 '13 at 11:23