Click here to Skip to main content
Licence 
First Posted 5 Jul 2007
Views 39,956
Bookmarked 47 times

Chatting Application Using DotNet

By | 5 Jul 2007 | Article
Chatting Application Using VB.Net (ConCurrent Server)

Download ServerForm.zip - 192.9 KB

Download ClientForm.zip - 196.7 KB

Screenshot - Server_Form1.jpg

Screenshot - Client_after_Conn.jpg

Introduction

Simple Chatting Application Using Socket Programming in VB.Net . This Application use TCP Protocol for Communication. So it is Connection Oriented and reliable Service.........

Background

Mainly Background is Socket Programming in VB.NET which use System.Net.Sockets NameSpace...

Client Socket::: TcpClient Class

Server Socket:: TcpListner Class

Socket is Combination of IP_Address and PortNo.. When we create Socket we have to give IP , Port No and Protocol..

Here DotNet give TcpClient Class which is by default use TCP Protocol.. we have to just provide IP And PortNo..

Same way For TcpListner Class also...............

Using the code

Connect Sub Will send Connection Request to server on given ip

after Connection Receive function is started using thread.. because receive function will go in infinite loop so we have to start receive funtion using Thread.otherwise your mainProcess will goes in infinite loop..

// Public Sub Connect()
        Try
            ipHostinfo = Dns.Resolve(Txtserver.Text)
            ipAdd = ipHostinfo.AddressList(0)
            remoteEP = New IPEndPoint(ipAdd, 11000)
            sender.Connect(remoteEP)
            th = New System.Threading.Thread(AddressOf Receive)
            th.Start()
            i = 1
            MessageBox.Show("Client Connected With Server->" + Txtserver.Text)
        Catch ex As Exception
            MessageBox.Show(ex.Message)

        End Try
        
    End Sub

if we use Multi threading architecture we get 1 main Problem Called: Cross Thread Problem

Solve this problem using Delegate Funtion..Here is Solution

 If Me.List.InvokeRequired Then
            Dim d As New SetDisplay(AddressOf Proccessdata)
            Me.Invoke(d, New Object() {str})
        Else
            Me.List.Items.Add(str)
Public Sub Receive()
        Dim bytes(100000) As Byte
        Dim bytesRec As Integer
   A:      While True
            bytes = New Byte(100000) {}
            bytesRec = sender.Receive(bytes)
            If bytesRec > 0 Then
                Data = Encoding.ASCII.GetString(bytes, 0, bytesRec)
                Exit While
            End If
           End While
        'List.Items.Add(Data)
        'MessageBox.Show(Data)
        Proccessdata(Data)
        ActionData(Data)
        GoTo A
End Sub
        Try
            msg = Encoding.ASCII.GetBytes(Txtmsg.Text)
            Me.sender.Send(msg)
            Txtmsg.Text = ""
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Points of Interest


Screenshot - Cd_Drive.jpg

This is part of Client Screen.. one intresting point that we can control server Cd Drive From Client Form...

You can Open Notepad , PainBrush ,Calculator On server Machine From Client Screen....

You Can Lock and Release Mouse of Client Pc From the Server....

You Can ShutDown and Restart client Computer From the Server.....

You Can Capture the Photo of Client Screen From the Server......

History

Keep a running update of any changes or improvements you've made here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

hiteshswce

Web Developer

India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberBillaBong12:05 1 Mar '11  
GeneralMy vote of 4 PinmemberParsagachkar21:33 8 Jan '11  
QuestionHow should i Get servers IP? PinmemberParsagachkar21:31 8 Jan '11  
QuestionHi PinmemberMember 46563022:47 30 Mar '09  
Generalthankes Pinmembergoldman14157:44 11 Jan '09  
Questiondoubt for declaration? Pinmembergowthamforever1:00 24 Dec '08  
Questionhow to chat the two system,but there is located in different location PinmemberPandian6020:00 12 Jul '08  
Questionwow Pinmemberkasif@kasif.org2:14 5 Aug '07  
GeneralGreat Article! PinmemberRyanPotter21:47 3 Aug '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 5 Jul 2007
Article Copyright 2007 by hiteshswce
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid