Hi All,
I just got around the writing the code for this. A couple of questions:
1) Regarding:
- when the openSockets contains all the addresses in your original
list, you're done
I'm not sure what you mean by "done", all servers will be connected
to the Client, but is there anything specific I need to do if/when
this happens. If the In my App if the Client is not connected to a
Server then nothing special happens, if it is connected then messages
are sent periodically.
2) In the socketError and socketTimeout handlers, how can I tell if
the error presented is because of a Connect to Server problem or a
general read/write problem? Can I just check in "the openSockets" and
if it's there assume it's from a read/write problem?
3) In my App, a Server is only allowed to Accept connections from
Certain Clients (this is controlled by the IP Address and a Value
passed to the Server in the Connection Request). This is my Accept
code:
function IStartServer theServerPortNumber
--
-- Accept Connection(s) from Client(s)
--
accept connections on theServerPortNumber with message
"ISMServerContactedByClient"
return empty
end IStartServer
on ServerContactedByClient theIPAddress
local myResult
--
-- Check for Error
--
put the result into myResult
if myResult <> empty then exit ServerContactedByClient
read from socket theIPAddress for kPacketCountSize chars with
message "ISMServerReceivedPacketSize"
end ServerContactedByClient
Can I just look up "theIPAddress" in "ServerContactedByClient" and if
it's not in the list of valid Clients, do do an "exit
ServerContactedByClient" to ignore the request?
Thanks a lot
All the Best
Dave
On 21 Feb 2008, at 21:36, Phil Davis wrote:
Hi Dave,
I don't have time to write sample code right now, but one approach
would be:
- set the socketTimeoutInterval to something reasonable
- make a 'connectToServerApp' handler that opens one socket, using
the params passed to it by 'startClient'
- let 'StartClient' do this once for each line in your server list:
send ("connectToServerApp" && tOneIpAddress) to stack in 0 ticks
- make a 'socketTimeout' handler than resends the
'connectToServerApp' cmd (with params) to stack in x ticks
- make a 'socketError' that notifies you of connection failures
- when the openSockets contains all the addresses in your original
list, you're done
Phil Davis
Dave wrote:
Hi All,
I have a number of applications that communicate with each other
using TCP/IP Sockets. For a given application, I want to be able
to connect it to a number of "server" applications, however the
"server" apps make or may not be running, so what I want to be
able to do is to issue an open socket to a "server" application
and if the connection is made add it to a "connected" table and if
not, carry on the to next server, but try to open the socket again
at a later time.
I can't seem to be able to get my head around the code needed to
do this!
Basically I have a Function that gets called with a list of the IP
Addresses in the for - aa.bb.cc.dd:port and a ConnectionID, I want
to be able to open a socket to each IP/Port with the specified
ConnectionID . The function definition for this is as follows:
function StartClient theConnectToServerList,theConnectionID
theConnectToServerList is a list of the following
192.168.1.100:6000
192.168.1.100:6002
192.168.1.100:6004
etc.
Any ideas on how achieve this gracefully would be greatly
appreciated!
All the Best
Dave
_______________________________________________
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