Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2009, 08:05 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default Indy UDP server.

I am using Indy UDP server component to receive some data from another program through a certain port. I know that the data will be received using “OnRead” event. But I am little bit lost on where to get it!!! Any suggestions?
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #2  
Old 11-06-2009, 07:25 PM
Ouiji Ouiji is offline
Senior Member
 
Join Date: Nov 2001
Location: US of A
Posts: 492
Default

I realize that this is not the answer you are looking for directly, but have you tried using the ICS socket component in place of the Indy component? Socket rutienes both TCP and UDP are much easier to manage in ICS and I have always personally found the Indy suite to be buggy. I would be happy to provide a simple example of doing this using ICS, please let me know if this might me something you would be willing to try.

ICS:
http://www.overbyte.be/frame_index.h...ducts/ics.html

ICS is also freeware, and comes with many examples.

-ouiji
__________________
"not quite smart enough to be dumb"
Extended Stats No Longer Available Due To Changes To The Forum.
Reply With Quote
  #3  
Old 11-07-2009, 07:48 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

I am using Indy UDP to get some data from a firewall program using a port number. I don't mine using the ICS socket component if it will do the job. Can you show me some example?
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #4  
Old 11-07-2009, 11:08 AM
Ouiji Ouiji is offline
Senior Member
 
Join Date: Nov 2001
Location: US of A
Posts: 492
Default

The code below is a snippet from a Syslog application I wrote to receive messages from my netscreen. I know it works for that purpose as I use it on a daily basis, I hope it is of use to you.


Using a TWSocketServer, set the 'Proto' property to udp. And obviously the port to the port you wish to use, and any other properties you wish to define.

[Optional]
I usually like to add in a "OnClientConnect" or "OnSessionAvailable" event to ensure the connection is actually making it to the destination. (Most time just have it trigger a simple status message to a TMemo)


Now on to the worthwhile information..

In the OnDataAvailable event, I have as follows:

Code:
procedure TForm1.ServerSocket1DataAvailable(Sender: TObject; ErrCode: Word);
var
s:string;
Begin

 s := s1.ReceiveStr;   // Set S to the received data

 if s <> '' then begin   // Do not proceed if there is no data

  // Do what you will with the data received and assigned to variable s


 end;
end;
Using the socket from ICS makes this quite simple, if you are still running into errors, or would like to take a look at the source to the Syslog application, feel free to message me and I will do my best to assist in any way I can.


Best Regards,
- ouiji
__________________
"not quite smart enough to be dumb"
Extended Stats No Longer Available Due To Changes To The Forum.
Reply With Quote
  #5  
Old 11-07-2009, 11:28 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

Big thanks ouiji,

I will try it tomorrow and I will get back to you. Thanks again....
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #6  
Old 11-10-2009, 05:46 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

ouiji,

Both works fine...thanks
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:37 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.