Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Socketwrench Client / Server do not connect
Message
De
18/06/2015 15:19:35
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01621147
Message ID:
01621158
Vues:
51
>>>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			&& TCP 
>#DEFINE swProtocolUDP 17		&& UDP
>#DEFINE swProtocolRAW 255		&& RAW
>
>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 && for testing - the server will be listening on 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 ?

Are the client and server on the same, or different, computers?

If the same, it's more conventional, and may work a little better to use localhost (127.0.0.1).

If different, you will need to either entirely disable the firewall on the server computer, or make a firewall exception for the server EXE (i.e. specifically allow that EXE to accept incoming traffic). If you have a firewall on the client machine that can restrict outgoing traffic you may have to set up an outgoing exception for the client EXE (or turn off the client firewall entirely).

Also, if SocketWrench is implemented as an ActiveX, you may have to set _VFP.AutoYield = .F.

DOEVENTS [FORCE] can also be useful if events are not being processed as expected.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform