henrythacker
asked on
MSN Protocol
Hi, ive read the documents on http://www.hypothetic.org/docs/msn/index.php and the whole MSN protocol sounds very easy, however, to implement the connection, it is seeming very difficult, the walkthrough talks about two server types, and the trouble is, i don't need much functionality in the application. I have been trying to use a TClientSocket to connect to the MSN server, and the connection seems to close, im not even sure whether the connection is set to be kept open during the session. I receive sucessfully the first reply from the server, but then when i send a session, it seems to disconnect unexpectedly.
Here's my code:
========================== ========== ========== ========== ========== ====
procedure TForm1.ClientSocket1Write( Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add(socket.Rec eiveText);
end;
procedure TForm1.ClientSocket1Error( Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
memo1.lines.add('error code:'+inttostr(errorcode) );
end;
procedure TForm1.ClientSocket1Connec ting(Sende r: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('Connectin g...');
end;
function sendcommand(command:string ):boolean;
begin
sleep(1000);
form1.clientsocket1.Socket .SendText( command+#1 3#10);
end;
procedure TForm1.ClientSocket1Connec t(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('Connected ');
sendcommand('VER 1 MSNP8 CVR0');
end;
procedure TForm1.ClientSocket1Read(S ender: TObject;
Socket: TCustomWinSocket);
var
a:string;
begin
a:=socket.ReceiveText;
memo1.lines.add('recvd:'+a );
//if a='VER 1 MSNP8 CVR0'+#13#10 then sendcommand('INF 1'); <-it would be preferable to issue this command following the receival of the last message from the server
end;
procedure TForm1.ClientSocket1Discon nect(Sende r: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('disconnec ting...');
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
sendcommand('INF 1');
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if clientsocket1.Active=true then panel1.color:=clgreen else panel1.color:=clred;
end;
end.
========================== ========== ========== ========== ========== ====
That is the whole code for the application ive written so far. There is a timer, set to 10ms, to display the status of the Socket, a button, which sends the secondary command which for some reason makes the socket disconnect, and a memo to display the socket messages. If anyone could give me a demo, or help, then i would be happy to give away some points! Thanks, Henry Thacker.
Here's my code:
==========================
procedure TForm1.ClientSocket1Write(
Socket: TCustomWinSocket);
begin
memo1.lines.add(socket.Rec
end;
procedure TForm1.ClientSocket1Error(
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
memo1.lines.add('error code:'+inttostr(errorcode)
end;
procedure TForm1.ClientSocket1Connec
Socket: TCustomWinSocket);
begin
memo1.lines.add('Connectin
end;
function sendcommand(command:string
begin
sleep(1000);
form1.clientsocket1.Socket
end;
procedure TForm1.ClientSocket1Connec
Socket: TCustomWinSocket);
begin
memo1.lines.add('Connected
sendcommand('VER 1 MSNP8 CVR0');
end;
procedure TForm1.ClientSocket1Read(S
Socket: TCustomWinSocket);
var
a:string;
begin
a:=socket.ReceiveText;
memo1.lines.add('recvd:'+a
//if a='VER 1 MSNP8 CVR0'+#13#10 then sendcommand('INF 1'); <-it would be preferable to issue this command following the receival of the last message from the server
end;
procedure TForm1.ClientSocket1Discon
Socket: TCustomWinSocket);
begin
memo1.lines.add('disconnec
end;
procedure TForm1.Button1Click(Sender
begin
sendcommand('INF 1');
end;
procedure TForm1.Timer1Timer(Sender:
begin
if clientsocket1.Active=true then panel1.color:=clgreen else panel1.color:=clred;
end;
end.
==========================
That is the whole code for the application ive written so far. There is a timer, set to 10ms, to display the status of the Socket, a button, which sends the secondary command which for some reason makes the socket disconnect, and a memo to display the socket messages. If anyone could give me a demo, or help, then i would be happy to give away some points! Thanks, Henry Thacker.
ASKER
That site is quite useful, but not what im looking for, the site is mainly based on the Yahoo messenger protocol, and doesn't have any complete delphi examples... does anyone have a TClientSocket or other internet client component based example?
ASKER
this is all good stuff, but this project has no source available as yet... if the source is released before this question is closed, please let me know, and i will award you the points. thank you. does any one, have any login code for MSN protocol?? Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, im still going to need to do some more work on this... but your code does seem to work fine.. thanks
http://pub66.ezboard.com/fcoreprogrammingfrm5