472,352 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 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 6826
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 =...
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...
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...
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...
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,...
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...
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...
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...
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...
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.