|
-
Aug 11th, 2000, 12:11 AM
#1
Thread Starter
New Member
I am trying to use Winsock without a form and can't figure out how to trap events such as DataArrival and Error.
Private Sub g_objWs_DataArrival(ByVal bytesTotal As Long)
doesn't seem to get called.
Can someone tell me how to do this?
Thanks
-
Aug 11th, 2000, 12:44 AM
#2
Junior Member
this might help
did you do these few things:
Winsock1.RemoteHost = "www.host.com"
Winsock1.RemotePort = 80
Winsock1.Connect
Private Sub Winsock1_Connect()
Dim strCommand As String
Dim strWebPage As String
strWebPage = "http://www.host.com/urpage.htm"
strCommand = "GET " + strWebpage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + vbCrLf
Winsock1.SendData strCommand
End Sub
after those two things, the dataarrival will be called. and you will have access to the error part also
ShadowWalker
webmaster of shadowkeep.com
-
Aug 11th, 2000, 09:04 AM
#3
Thread Starter
New Member
Thanks for the reply.
In the following snippet, Sub g_objWs_Connect() is never called.
----------------------------------------
Public g_objWs As MSWinsockLib.Winsock
Sub Main()
Set g_objWs = New MSWinsockLib.Winsock
g_objWs.RemoteHost = udtParms.strAddress
g_objWs.RemotePort = MAILPORT
g_objWs.Connect
While g_objWs.State <> sckConnected
DoEvents
Wend
MsgBox "Connected"
End Sub
Private Sub g_objWs_Connect()
MsgBox "connect event"
End Sub
-----------------------------------------
I have code that works fine when I drag a Winsock component onto a form, but my app will run as a formless background task.
Thanks,
Cranky
-
Aug 11th, 2000, 01:34 PM
#4
Junior Member
control load
did u load a control for winsock at runtime? that really is the only thing i can think ove. i can remember how to load it at runtime but i know i read it in one of the posts in here. so maybe that is what is wrong
ShadowWalker
webmaster of shadowkeep.com
-
Aug 12th, 2000, 01:18 PM
#5
Thread Starter
New Member
Thanks
Hey, thanks for sticking with me on this.
>>did u load a control for winsock at runtime?
I think that:
Set g_objWs = New MSWinsockLib.Winsock
does this.
Anyway, I gave up and used an invisible form with the winsock component on it.
Thanks again,
Cranky
-
Aug 12th, 2000, 02:19 PM
#6
Junior Member
welcome
sorry i couldnt help anymore. i havnt gotten to the point of using a formless progi yet. im sure to have the same problem if i ever do =)
ShadowWalker
webmaster of shadowkeep.com
-
Aug 12th, 2000, 05:00 PM
#7
Monday Morning Lunatic
Cranky
Check out the WithEvents keyword. Basically, you declare your Winsock control, but add WithEvents after the Dim (or something like that). Then, add declarations for the events, and it works! (we hope)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 12th, 2000, 06:22 PM
#8
Fanatic Member
i havn't tried it, but i think parksie is right with the WithEvents buissiness.
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 14th, 2000, 11:17 AM
#9
Guru
First you must add a reference to MS Winsock. This MUST be done through PROJECT --> REFERENCES and NOT PROJECT --> COMPONENTS. Just browse to MSWinsck.ocx using the browse button.
Then add this code to a class module
Code:
Private WithEvents m_objSock As MSWinsockLib.Winsock
Private Sub Class_Initialize()
Set m_objSock = New MSWinsockLib.Winsock
End Sub
You can then capture Winsock events without using forms
Tom
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|