If I drag a tcpsocket to a window and call
tcpsocket1.address="www.google.com"
tcpsocket1.port=80
tcpsocket1.connect
the connected event fires. cool.
If I put in code
dim mytcpsocket = new tcpsocket
mytcpsocket.address="www.google.com"
mytcpsocket.port=80
mytcpsocket.connect
if not mytcpsocket.isconnected then
msgbox "error"
end
guess what? Error. Not cool! (even though lasterrorcode returns 0)
but if I add a handler to the above before connecting
addhandler mytcpsocket.connect, addressof mytcpisconnected
and then create a method
Protected Sub mytcpisconnected(mytcp as TCPSocket)
MsgBox "connected"
End Sub
It connects! Cool!
So, while I did eventually solve my problem, I would like this to be a learning experience and take some knowledge away from it that I can possibly use in the future.
Can someone explain why the simple in-code example doesn't work?
Thanks!
