MSN messenger protocol implementation

Hi, I am trying to implement MSN messenger protocol in VB.Net. It works in VB 6, but for some reason I cannot get any response from the messenger server when I use VB.Net.
Here is the code that works with VB 6.

Private Sub cmdLogin_Click()
wnsckMSN.RemoteHost = ""
wnsckMSN.RemotePort = 1863
End Sub

Private Sub wnsckMSN_Connect()
wnsckMSN.SendData "VER 0 MSNP7 MSNP6 MSNP5 MSNP4 CVRO" & vbCrLf
End Sub

Private Sub wnsckMSN_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
wnsckMSN.GetData strdata
Debug.Print strdata
End Sub

When I try to do the same in VB.Net usiong TcpClient I dont get back any response. I should get back a string like: "VER 0 MSNP7 MSNP6 MSNP5 MSNP4", which I do get in VB 6. Here is the code for VB.Net:


Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
Dim trialID As Integer
Dim networkStream As System.Net.Sockets.NetworkStream
Dim tcpClient As New System.Net.Sockets.TcpClient()

#Region " Windows Form Designer generated code "
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tcpClient.Connect("", 1863)
trialID = 0
networkStream = tcpClient.GetStream()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If networkStream.CanWrite Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("VER 0 MSNP7 MSNP6 MSNP5 MSNP4 CVRO " & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If networkStream.DataAvailable Then
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

Dim returndata As String = Encoding.ASCII.GetString(bytes)
TextBox1.Text = returndata
If Not networkStream.CanRead Then
MessageBox.Show("You can not write data to this stream")

End If
End If
End Sub

End Class

Can anybody point out what's wrong with my VB.Net code. By the way, when I create my own local server using TcpListner and connect to my server then I do get a response from my server. So, I don't think there is anything wrong with the way I am connecting.
Any help will be highly appreciated.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!