Socket Accept/Connection Question/Problem

Dave dave at looktowindward.com
Thu Feb 28 09:54:28 EST 2008


Hi,

Thanks for this, unfortunately, I can't open the App as a Process  
since it may not be there at that time and also the Server and  
Clients could be on different machine of the LAN. This are also many  
clients of the Server, each of these may or may not also act as a  
Server.

All I want to do is to know if a Client successfully connected to a  
Server, surely this is what the openSocket command is for.

Surely the:

   open socket mySocketAddress with message "ClientSocketOpen"

Statement should call "ClientSocketOpen" if the Server accepted the  
connection or call "socketError" or "socketTimeout" if there was an  
error? e.g. the Server closed the socket?

All the Best
Dave


On 28 Feb 2008, at 13:22, Eric Chatonet wrote:

> 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: eric.chatonet at sosmartsoftware.com/
> ----------------------------------------------------------------
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>





More information about the use-livecode mailing list