Clay Shannon wrote:
>> Is it possible to send messages from my client app to my server app
>> on the same machine (they are both running on the  same machine
>> during development/testing)?

Of course!

>> 
>> I would assume so, but it's not working. Specifically, the server
>> app's ClientConnect() event is not firing. This is where the 
>> OnDataAvailable() event is hooked up. Since ClientConnect() does not
>> fire, the Server never "gets" the message sent.
>> 
>> Here is the pertinent code:
>> 
>> CLIENT APP:
>> 
>> Sending the message to the Server app running on the same machine:
>> 
>>   if not (ICSSocket_Sending.State = wsConnected) then begin
>>     { Not connected yet, start connection }
>>     ICSSocket_Sending.Addr := '127.0.0.1';
>>     ICSSocket_Sending.Port := 42;
>>     ICSSocket_Sending.Connect;
>>   end;
>>   ICS_SendString('Bla bla bla');

ICS works asynchronous, means when ICSSocket_Sending.Connect
returns you are not necessarily connected yet. Send your first bytes
from OnSessionConnected. However you should get an exception if
you are not connected when sending something.

>> 
>> SERVER APP:
>> 
>> 1a).
>> {--------------------------------------------------------------------
>> ------- ---}
>> procedure TfJCPServer.FormShow(Sender: TObject);
>> begin
>>   PostMessage(Handle, WM_APPSTARTUP, 0, 0);
>> end;
>> 
>> 1b).
>> Set port to listen to:
>> {--------------------------------------------------------------------
>> ------- ---}
>> procedure TfJCPServer.WMAppStartup(var Msg: TMessage);
>> begin
>>   { Listen to messages from the Client app }
>>   ICSSocketServer_Listening_ClientApp.Port := 42;
>>   ICSSocketServer_Listening_ClientApp.Addr := '0.0.0.0';  { Use any
>> interface }
>>   { This prevents the typecasts from failing }
>>   ICSSocketServer_Listening_ClientApp.ClientClass := TTcpSrvClient;
>> { Use our component }
>>   ICSSocketServer_Listening_ClientApp.Listen;                      
>> { Start listening    }
>> end;

Where do you assign OnClientConnect?

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to