Hi Dave,

We use TCP to communicate between a GUI and a process that manages internet captures and a SQL db.
Both apps act as a client AND a server.
Initialization sequence is:
1. The main app opens a socket as a client then opens the other app as a process. 2. When the process opens it opens another socket as a client and the same than the main app as a server. 3. The process sends a message to the main app to ask it to open the corresponding socket to act as a server. If the main app does not receive the message it expects (with a timeout we fix) it means that something wrong happened.
Otherwise it sends a 'Done' message to the process.
4. The main app sends a 'ping' message to verify that double client/ server connection has been correctly established in both directions.
When all this has been done, you know that communication is OK :-)

Best regards from Paris,
Eric Chatonet.

Le 28 févr. 08 à 14:04, Dave a écrit :

Hi All,

I am using Sockets to communicate between Applications. In this example, one Application is a "Server" and the other is a "Client". The Server issues a connected command and specifies a Callback handler as so:

accept connections on theServerPortNumber with message "ServerContactedByClient"

on ServerContactedByClient theIPAddress
  local myClientIPAddress
  local myResult

  put the result into myResult

  if myResult <> empty then
    breakpoint
    exit ServerContactedByClient
  end if

  set the itemDelimiter to ":"
  put item 1 of theIPAddress into myClientIPAddress

if myClientIPAddress is not among the lines of sgServerClientAllowList then
    close socket theIPAddress
  end if

read from socket theIPAddress for 8 chars with message "ServerReceivedPacketSize"

end ServerContactedByClient

I am testing the error handling when a Client tries to connect but that server doesn't allow it to connect. The "ServerContactedByClient" gets called and the IP address is NOT is present in the "sgServerClientAllowList" (a Script Global), so the close socket is executed. However on the Client I have the following code:

  open socket mySocketAddress with message "ClientSocketOpen"


on ClientSocketOpen theIPAddress
  local myConnectString
  local myConnectionID
  local myResult


  put the result into myResult
  if myResult <> empty then
    breakpoint
    exit ClientSocketOpen
  end if

  --
  --  Send the Connect Message, Start with the Count
  --
  put "Connect," & myConnectionID into myConnectString
write myConnectString to socket theIPAddress with message "ClientSocketConnectionDataSent"
end ClientSocketOpen

The "ClientSocketOpen" handler is called but the "ClientSocketConnectionDataSent" handler is never called, as I would expect, since the Server closed the Socket, however, the socketError or sockTimeout handler are not called either?

My question is, how can the Client tell if the connection has been successful or not?

----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/
----------------------------------------------------------------


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to