>>Hi Gang!
>>
>>I am in the process of converting some old Delphi 6 client code to VFP 9.0 SP1. The Delphi code makes a connection to a pill dispenser, then once connected, it reads in files from a folder, takes each file and reads the data in it to a variable, and then writes that data to the pill dispenser. Once done with that file, it deletes the file and continues to the next file.
>>
>>I've done the conversion to VFP. Since I don't have access to the Pill Dispensers ( $$$$$$$$$ ) for testing, I wrote a Server program to stand in for it. The server is based on the code in the Catalyst Socketwrench literature ( it is the Developers Guide and Technical Reference for Socketwrench 4.5). The Server program listens on Port 7 (as per the instructions as best I understand it). All it does is listen on Port 7 (for testing), and displays on the form what the client sends over to it.
>>
>>I have given the client code and the server code the same Local Address and Local Port, but it will not connect to each other. I turned off the Windows Firewall (I think I did...), but still no connection to each other.
>>
>>Any ideas of why the client and server do not connect ?
>
>Assuming it's using TCP/IP, it's not a good idea to use ports under 1023 as many of those are reserved for certain things. Can you easily try, say, port 10007 rather than port 7?
Did not connect with 10007
Here is my Client connection code in my m_reconnect method....
p_testing is .T. in this case, for testing the code.
The socket is in Non-Blocking mode, so the socket does not hang on, but allows the code to continue and wait until the OnConnect or the OnError event fires.
LPARAMETERS llAddon
LOCAL lcTable as String
LOCAL lcIP as String
LOCAL lnPort as Integer
#DEFINE swProtocolTCP 6
#DEFINE swProtocolUDP 17
#DEFINE swProtocolRAW 255
IF NOT Thisform.clientsocket.Connected
IF NOT Thisform.p_testing
lcIP = ALLTRIM(Thisform.p_pillip)
lnPort = Thisform.p_pillport
ELSE
lcIP = '192.168.40.15'
lnPort = 10007
ENDIF
Thisform.clientsocket.AutoResolve = .F.
Thisform.clientsocket.Blocking = .F.
Thisform.clientsocket.protocol = swProtocolTCP
Thisform.txtStatusPanel0.Value = 'IP Address: ' + lcIP
Thisform.txtStatusPanel1.Value = 'Port: ' + ALLTRIM(STR(lnPort))
IF llAddon
Thisform.txtStatusPanel2.Value = Thisform.txtStatusPanel2.Value + ' Connecting...'
ELSE
Thisform.txtStatusPanel2.Value = 'Connecting...'
ENDIF
Thisform.clientsocket.Disconnect
lnError = Thisform.clientsocket.Connect(lcIP, lnPort)
IF lnError <> 0
Thisform.txtStatusPanel2.Value = 'Connection error'
ENDIF
ENDIF
Thisform.Refresh
We never get to the Onconnect event, but we DO get to the OnError event after about 30 seconds of the program waiting around for an event to happen.
Anything you see I can try ?
Thanks!!
Tommy Tillman A+ NetWork+ MCP