 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
jacky Guest
|
Posted: Mon Nov 22, 2004 4:14 am Post subject: Can the socket-client programmed with VB work with the socke |
|
|
Recently I wrote a socket client program with VB. And I wrote a server
program with Indy 9 TidTCPServer too. Then I think it should be no problem
that the client connects the server. But it is not like I think. I met some
trouble. The server can only connects with client. It can not read any
messages from client. I also debuged it with adding breakpoint in ReadLn
line on the IdTCPServerExecute() event. But it is not response. I don't know
what it's problem. Anyone can help me answer this question. Why they can not
work ?
There are some code in server program:
procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
var
sCommand,ReplyMessage: string;
Datas:TStrings;
begin
Datas:=TstringList.Create ;
with AThread.Connection do begin
sCommand := ReadLn(); ////////////it's no response with debuging.
FLogEntry := sCommand + ' from client '+
AThread.Connection.Socket.Binding.PeerIP;
AThread.Synchronize(AddLogEntry);
SplitStrings(Datas,sCommand,'|');
if Datas[0]<>'' then ////start
begin
if Datas[0]='CheckLogin' then begin
ReplyMessage:='CheckLogin';
AdoQuery1.SQL.Text :='execute CheckLoginAccount
@CheckMan='''+Datas[1]+
''',@Password='''+Datas[2]+'''';
AdoQuery1.Open ;
if AdoQuery1.RecordCount=0 then
ReplyMessage:=ReplyMessage+'|0'
else
ReplyMessage:=ReplyMessage+'|1';
FReceived := sCommand;
WriteLn(ReplyMessage);
AThread.Synchronize(DisplayData);
end
end;
end;
end;
Thanks.
jacky
|
|
| Back to top |
|
 |
Martin James Guest
|
Posted: Mon Nov 22, 2004 9:33 am Post subject: Re: Can the socket-client programmed with VB work with the s |
|
|
Sounds like mismatched line terminators to me. VB sending LF, Indy expecting
CR, something like that.
Rgds,
Martin
|
|
| Back to top |
|
 |
Ciaran Costelloe Guest
|
Posted: Wed Nov 24, 2004 10:23 pm Post subject: Re: Can the socket-client programmed with VB work with the s |
|
|
Get the (free) packet sniffer Ethereal, it will show you exactly what is
being transmitted, and you can learn what is going on.
Ciaran
"jacky" <jacky.ke.jin (AT) 126 (DOT) com> wrote
| Quote: | Recently I wrote a socket client program with VB. And I wrote a server
program with Indy 9 TidTCPServer too. Then I think it should be no problem
that the client connects the server. But it is not like I think. I met
some
trouble. The server can only connects with client. It can not read any
messages from client. I also debuged it with adding breakpoint in ReadLn
line on the IdTCPServerExecute() event. But it is not response. I don't
know
what it's problem. Anyone can help me answer this question. Why they can
not
work ?
There are some code in server program:
procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
var
sCommand,ReplyMessage: string;
Datas:TStrings;
begin
Datas:=TstringList.Create ;
with AThread.Connection do begin
sCommand := ReadLn(); ////////////it's no response with debuging.
FLogEntry := sCommand + ' from client '+
AThread.Connection.Socket.Binding.PeerIP;
AThread.Synchronize(AddLogEntry);
SplitStrings(Datas,sCommand,'|');
if Datas[0]<>'' then ////start
begin
if Datas[0]='CheckLogin' then begin
ReplyMessage:='CheckLogin';
AdoQuery1.SQL.Text :='execute CheckLoginAccount
@CheckMan='''+Datas[1]+
''',@Password='''+Datas[2]+'''';
AdoQuery1.Open ;
if AdoQuery1.RecordCount=0 then
ReplyMessage:=ReplyMessage+'|0'
else
ReplyMessage:=ReplyMessage+'|1';
FReceived := sCommand;
WriteLn(ReplyMessage);
AThread.Synchronize(DisplayData);
end
end;
end;
end;
Thanks.
jacky
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|