Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MSN Protocol

Posted on 2003-10-27
7
469 Views
Last Modified: 2010-08-05
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.ReceiveText);
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
memo1.lines.add('error code:'+inttostr(errorcode));
end;

procedure TForm1.ClientSocket1Connecting(Sender: TObject;
  Socket: TCustomWinSocket);
begin
memo1.lines.add('Connecting...');
end;

function sendcommand(command:string):boolean;
begin
sleep(1000);
form1.clientsocket1.Socket.SendText(command+#13#10);
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
memo1.lines.add('Connected');
sendcommand('VER 1 MSNP8 CVR0');
end;

procedure TForm1.ClientSocket1Read(Sender: 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.ClientSocket1Disconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
memo1.lines.add('disconnecting...');
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.
0
Comment
Question by:henrythacker
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9625684
There is some useful information at
http://pub66.ezboard.com/fcoreprogrammingfrm5
0
 
LVL 1

Author Comment

by:henrythacker
ID: 9636674
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?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9637996
Check out this project:
MSN++ http://sourceforge.net/projects/msnpp/
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:henrythacker
ID: 9639956
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.
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9640779
0
 
LVL 6

Accepted Solution

by:
GloomyFriar earned 125 total points
ID: 9640798
I've tried to send a couple of commands and it works fine.

procedure TFormMain.ClientSocket1Write(Sender: TObject;
 Socket: TCustomWinSocket);
begin
//memo1.lines.add(socket.ReceiveText);
end;

procedure TFormMain.ClientSocket1Error(Sender: TObject;
 Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
 var ErrorCode: Integer);
begin
memo1.lines.add('error code:'+inttostr(errorcode));
end;

procedure TFormMain.ClientSocket1Connecting(Sender: TObject;
 Socket: TCustomWinSocket);
begin
memo1.lines.add('Connecting...');
end;

function sendcommand(command:string):boolean;
begin
FormMain.clientsocket1.Socket.SendText(command + #13 + #10);
end;

procedure TFormMain.ClientSocket1Connect(Sender: TObject;
 Socket: TCustomWinSocket);
begin
memo1.lines.add('Connected');
end;

procedure TFormMain.ClientSocket1Read(Sender: TObject;
 Socket: TCustomWinSocket);
var
a:string;
begin
a:=socket.ReceiveText;
memo1.lines.add('recvd:'+a);
end;

procedure TFormMain.ClientSocket1Disconnect(Sender: TObject;
 Socket: TCustomWinSocket);
begin
memo1.lines.add('disconnecting...');
end;

procedure TFormMain.Button1Click(Sender: TObject);
begin
sendcommand('VER 1 MSNP8 CVR0');
//sendcommand('VER 0 MSNP7 MSNP6 MSNP5 MSNP4 CVR0');
end;

procedure TFormMain.Timer1Timer(Sender: TObject);
begin
if clientsocket1.Active=true then panel1.color:=clgreen else panel1.color:=clred;
end;

procedure TFormMain.Button2Click(Sender: TObject);
begin
sendcommand('CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS example@passport.com');
end;
0
 
LVL 1

Author Comment

by:henrythacker
ID: 9657193
Thanks, im still going to need to do some more work on this... but your code does seem to work fine.. thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 138
Working with hours 3 64
Tembedded WB animatid gifs not animated on some pcs 2 83
JAudiorecorder record freezing the app 29 74
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question