Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 12th, 2004, 06:51 AM
Xian Xian is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 24 Xian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
receive strings

Hi Guys!
my program has to send strings of text to a remote device and then recive strings by it; my problem is that I can't reive these strings, this is the procedure to send and (but it doesn't!) receive strings:

procedure TfrmMain.memLogKeyPress(Sender: TObject; var Key: Char);
var
s: string;
begin

if Key = #13 then
begin

sockForward.Socket.SendText(memLog.Lines[memLog.Lines.Count - 1]);
s:=sockForward.Socket.ReceiveText;
AddLog('received message: ' + s);

end;
end;

can you help me??
I send also the entire project!
Thank You!!

Christian
Attached Files
File Type: zip Forwarder.zip (9.9 KB, 325 views)

Reply With Quote
  #2  
Old October 12th, 2004, 09:53 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
Quote:
Originally Posted by Xian
my problem is that I can't reive these strings


What does it do? Does it hang, continue with a zero-length string, show garbage, ... ?

Also, can we see a few lines of your sending function?

M.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old October 12th, 2004, 10:11 AM
Xian Xian is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 24 Xian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hirsch, thank you for replying!
the procedure that I wrote is the sending one!!
simply, it doesn't work well, in fact when I press the enter key it sends the strings (the windows network icons flashes) but I receive nothing, no return messages!!!
Can you help me??
Thank You.

Christian

Reply With Quote
  #4  
Old October 12th, 2004, 10:22 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
So that function is sending the text to itself?

Ok, that's probably why it doesn't work. Timing problems. The text is not yet in the receive buffer directly after sending it. Put the ReceiveText-part in a "OnClientRead" handler instead. It should work then.

M.

Reply With Quote
  #5  
Old October 12th, 2004, 10:41 AM
Xian Xian is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 24 Xian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can you give me an example of onclientread event handler please??
thank you!!!

Reply With Quote
  #6  
Old October 12th, 2004, 10:46 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
This is code from one of my Delphi 5 projects, but the version should not matter:

Code:
procedure TChatClientForm.ClientRead(Sender: TObject; Socket: TCustomWinSocket);
begin
  Memo1.Lines.Add('Client read from '+Socket.RemoteAddress+' data follows:');
  while Socket.ReceiveLength>0 do begin
    Memo1.Lines.Add('* '+Socket.ReceiveText);
  end;
end;

Ah ja, and set the ClientType to "ctNonBlocking" to make it work.

hth,
M.

Reply With Quote
  #7  
Old January 30th, 2005, 03:41 PM
Rink Rink is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 Rink User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 20 sec
Reputation Power: 0
I think (if I understand the point of the procedure) that you must be holding a button down before anything will be sent or RECEIVED and also you must also be holding down a certain button.... This means for you to receive anything you must always be holding that button down....

If I havent understood the way the proc is working sorry for writing this

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > receive strings


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT