Hi All
I am struggling with a strange problem when trying to set up a TCP/IP Client using the Winsock ActiveX control. Everything works fine if I run the code from the command line, entering ONE line at a time, like this:
ox = CREATEOBJECT( "MSWinsock.Winsock.1)
ox.RemoteHost = 'acs-server'
ox.RemotePort = 1001
ox.Connect()
? ox.State
ox.SendData( "Something or other" )
ox.Close()
RELEASE ox
However, if I paste EXACTLY the same code into a PRG file, or method of a class, and run it the connection fails. The test for State goes through values of 4 (Resolving host), then 6 (Connecting) and then immediately to 8 (Closing).
(Note: The ConnectionRequest event on the TCP server does not fire either!).
Remember, this is the same code, on the same client machine, connecting to the same host.
If I place a SET STEP ON in the program before the call to Connect() everything works just fine - the connection succeeds and all is sweetness and light. So, it's obviously a timing issue, right!
However, I have played with every combination of INKEY(), AutoYield, DOEVENTS and SYS(2033) that I can think of and NOTHING works. Remember, from the command line it is fine, with SET STEP ON in the code it is fine, but in a PRG without SET STEP it fails every time.
I must be missing something obvious, but for the life of me I cannot see it, nor can Marcia. Any help would be more than appreciated, it will earn the supplier a free copy of MegaFox <g>
----
Regards
Andy Kramek