473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Open Socket

14
Hi,

How can I open socket in ASP?

I want exact functionality like fsockopen function in PHP.

Thanks..

Ankit
Sep 29 '06 #1
2 6933
sashi
1,754 Expert 1GB
Hi there,

Kindly refer to below sample code segment, hope it helps you to get started with, take care my fren.. :)

' You need the FREEWARE ASocket.dll to run the sample.
' Download it from http://www.vahland.com/pub/asocket.dll
' and register it on your machine.
' Read http://www.vahland.com/pub/asocket.htm for more info


Expand|Select|Wrap|Line Numbers
  1. ' Constants: Connection states
  2. Const asCONN_DISCONNECTED=1
  3. Const asCONN_LISTENING=2
  4. Const asCONN_CONNECTED=3
  5.  
  6. ' Constants: Some Error codes
  7. Const asERR_SUCCESS=0
  8. Const asERR_INVALIDPARAMETER=1
  9. Const asERR_CREATETHREADFAILED=2
  10. Const asERR_EVALUATIONEXPIRED=3
  11. Const asERR_INVALIDLICENSE=4
  12.  
  13. ' Constants: Protocols
  14. Const asPROTOCOL_RAW=1
  15. Const asPROTOCOL_TELNET=2
  16.  
  17. ' Create a socket instance
  18. WScript.Echo "Be sure to have the FREEWARE ASocket.dll registered on your system"
  19. WScript.Echo "Check out the code header about how to obtain the component."
  20. Set asObj = CreateObject("ActivXperts.Socket")
  21. asObj.Protocol = asPROTOCOL_TELNET
  22.  
  23. ' Write some information to console
  24. WScript.Echo "ActivSocket " & asObj.Version & " demo."
  25.  
  26. ' Make a connection to port 1500 on remote server
  27. asObj.Connect "www.activxperts.com", 80
  28. Wscript.Echo "Connect to www.activxperts.com:80, result: " & asObj.LastError
  29. If asObj.LastError = 11001 Then
  30. WScript.Echo "Error 11001: Specify a valid hostname-parameter in the Connect-method."
  31. End If
  32.  
  33. If asObj.LastError = asERR_SUCCESS And asObj.ConnectionState = asCONN_CONNECTED Then
  34.  
  35.     ' YES, connection established.
  36.     WScript.Echo "Connection established" & vbCrLf
  37.  
  38.     strReceived = ""
  39.     nCounter = nCounter + 1
  40.  
  41.     asObj.Sleep 1000
  42.  
  43.     asObj.SendString "GET /activsocket/demopage/ HTTP/1.1", True
  44.     asObj.SendString "Host: www.activxperts.com" & vbCrlf, True
  45.  
  46.     asObj.Sleep 1000
  47.  
  48.     If asObj.HasData Then
  49.         strReceived = asObj.ReceiveString
  50.       WScript.Echo "RECV: " & strReceived
  51.     End If
  52.  
  53.     asObj.Sleep 1000
  54.  
  55. ' And finally, disconnect
  56.     asObj.Disconnect
  57. End If
  58.  
Sep 29 '06 #2
aplus
14
Hi Shashi...

Thanks for the reply.

-Ankit
Sep 30 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Dennis Hueckelheim | last post by:
Hallo everybody, I have a problem with a little socket script. ----- snipp ----- $out_clients = socket_accept($socket_out); $http_welcome = "HTTP/1.0 200 OK\r\nContent-type:...
27
by: Mike | last post by:
Open source programs in general suck pretty bad also. Here are some loose facts regarding why projects like Linux, PHP, MYSQL, and other open source programs suck: - Linux is simply a clone of...
1
by: rooster575 | last post by:
I would like to force a socket closed if it is currently open. For arguments sake, say a function failed to close a socket and another function would like to use this same socket. I get the...
1
by: Jay | last post by:
I have a client app sending messages over the socket on a certain port. In the client app: I do this for every message I need to send: 1. Create a socket and connect. 2. Send message 3. Close...
6
by: Maxim Veksler | last post by:
Hi, I've written this code, the general idea was to listen on all 65535 port of tcp for connection. """ #!/usr/bin/env python import socket, select def...
0
by: alf | last post by:
Hi, I need a help with explaining following behavior. Although it is not python issue per say, python helped me to write sample programs and originally I encountered the issue using python...
2
by: cookspyder | last post by:
In reference to streaming data over socket: Any one know how to keep a IO socket open while sending data everytime my while loops runs and collects data the connection closes and while the loop...
2
by: jlparise | last post by:
Hey everyone, I am really rusty on my Java socket programming and am having some confusing problems. I don't need the code debugged(even though it doesn't work). I'm not going to make you dig...
13
by: Alan Wright | last post by:
Hi Folks, I am newbie to Python, but have successfully created a simple client and server setup, I have one issue though. I am trying to test a box by sending many TCP conns (WHILE loop) but not...
0
by: Gary Herron | last post by:
Greg Lindstrom wrote: Here's a snippet of code I use to open a spreadsheet (given as a file path name), and compute and return the list of sheets it contains. It connects to an existing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.