Results 1 to 3 of 3

Thread: Source Code for a Chat Program

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    19

    Post

    Hi, I've looked around but can't seem to find any info on this.

    Can someone tell me where I can find source code for a chat program? (in VB, of course)

    Thanx in advance

  2. #2
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    This code snippet is for chat client....you need to add two seperate projects for chat server and client.

    Private Sub cmdConnect_Click()
    With sckClient
    .RemoteHost = "localhost"
    .RemotePort = 32000
    .Connect
    End With
    End Sub

    Private Sub cmdSend_Click()
    If Len(txtMsg.Text) Then
    sckClient.SendData txtMsg.Text
    End If
    End Sub

    Private Sub sckClient_DataArrival(ByVal bytesTotal As Long)
    Dim sTemp As String
    sckClient.GetData sTemp, vbString, bytesTotal
    txtHistory.Text = txtHistory.Text & sTemp & vbCrLf
    End Sub

    ------------------------------

    code for chat server
    ------------------------------

    Private Sub cmdSend_Click()
    If Len(txtMsg.Text) Then
    sckServer.SendData txtMsg.Text
    End If
    End Sub

    Private Sub Form_Load()
    With sckServer
    .LocalPort = 32000
    .Listen
    End With
    End Sub

    Private Sub sckServer_ConnectionRequest(ByVal requestID As Long)
    With sckServer
    If .State <> sckClosed Then
    .Close
    .Accept requestID
    End If
    End With
    End Sub

    Private Sub sckServer_DataArrival(ByVal bytesTotal As Long)
    Dim sTemp As String
    sckServer.GetData sTemp, vbString, bytesTotal
    txtHistory.Text = txtHistory.Text & sTemp & vbCrLf
    End Sub

    ------------------------------------

    All you need to do is in the remote host specify the ip address of the client machine..you need to run the program in the client machine too..if u need to try it in the same machine..just copy it as it is..

    Good Luck.

    Regards,

    Venkat

    ------------------
    [email protected]
    ICQ: 45714766
    http://venkat.iscool.net

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    If you did install the VB Books Online there's a nice example and everything's explained...

    ------------------
    Fox
    [email protected]
    [No homepage yet]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width