Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WinSock TCP/IP Client Problem
Message
From
12/01/2002 15:33:45
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
WinSock TCP/IP Client Problem
Miscellaneous
Thread ID:
00603962
Message ID:
00603962
Views:
93
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' && Substitute server name
ox.RemotePort = 1001  && Substitute as needed
ox.Connect()
? ox.State  && Returns 7 (Connected)
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
Next
Reply
Map
View

Click here to load this message in the networking platform