Results 1 to 12 of 12

Thread: problems with chat program

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    problems with chat program

    as pino told me to do im posting this here

    the problems are that my client wont send data or i might be to the server for everyone to see but the server isnt getting any of the info to display heres the send function of my code along with the data arrival of the server which is the same as the code for client


    VB Code:
    1. Private Sub cmdsend_Click()
    2. For i = 0 To server.ubound - 1
    3.         If client(i).State = sckConnected Then
    4. client(i).SendData txtnickname.Text & ": " & txtmsg.Text
    5.         End If
    6.    DoEvents
    7. Next i
    8. txtchat.Text = txtchat.Text & txtnickname.Text & ": " & txtmsg.Text & vbNewLine
    9. txtmsg.Text = ""
    10. End Sub


    VB Code:
    1. Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
    2. client(i).GetData msgarrived, vbString
    3. txtchat.Text = txtchat.Text & msgarrived & vbNewLine
    4. End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: problems with chat program

    Quote Originally Posted by BladeZ
    as pino told me to do im posting this here

    the problems are that my client wont send data or i might be to the server for everyone to see but the server isnt getting any of the info to display heres the send function of my code along with the data arrival of the server which is the same as the code for client


    VB Code:
    1. Private Sub cmdsend_Click()
    2. For i = 0 To server.ubound - 1
    3.         If client(i).State = sckConnected Then
    4. client(i).SendData txtnickname.Text & ": " & txtmsg.Text
    5.         End If
    6.    DoEvents
    7. Next i
    8. txtchat.Text = txtchat.Text & txtnickname.Text & ": " & txtmsg.Text & vbNewLine
    9. txtmsg.Text = ""
    10. End Sub


    VB Code:
    1. Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
    2. client(i).GetData msgarrived, vbString
    3. txtchat.Text = txtchat.Text & msgarrived & vbNewLine
    4. End Sub

    post your app for me

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    Server
    VB Code:
    1. Option Explicit
    2. Dim msgarrived As String
    3. Dim i As Integer
    4.  
    5. Private Sub cmdsend_Click()
    6. For i = 0 To server.ubound - 1
    7.         If server(i).State = sckConnected Then
    8.                 server(i).SendData txtnickname.Text & ": " & txtmsg.Text
    9.         End If
    10.    DoEvents
    11. Next i
    12. txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
    13. txtmsg.Text = ""
    14. End Sub
    15.  
    16.  
    17. Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
    18. Dim newClient As Long
    19.     If Index = 0 Then
    20.     'this is the listening server
    21.     'load a new control to talk to this client
    22.         newClient = LoadNextServer(server)
    23.         server(newClient).Accept requestID
    24.         server(newClient).SendData "Hello: you are connected"
    25.     End If
    26. End Sub
    27.  
    28. Private Sub server_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    29. txtchat.Text = msgarrived & vbNewLine
    30. End Sub
    31.  
    32. Private Sub server_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    33. Call server_Close(Index)
    34. End Sub
    35.  
    36. Private Sub server_Close(Index As Integer)
    37.     server(Index).Close
    38.     Unload server(Index)
    39. End Sub
    40.  
    41. Function LoadNextServer(wsServer) As Long
    42. Dim wsck
    43. Dim i As Long
    44.     i = 0
    45.     For Each wsck In wsServer
    46.         If wsck.Index > i Then
    47.             LoadNextServer = i
    48.             Load wsServer(i)
    49.             Exit Function
    50.         Else
    51.             i = i + 1
    52.         End If
    53.     Next
    54.     LoadNextServer = i
    55.     Load wsServer(i)
    56. End Function

    Client
    VB Code:
    1. Option Explicit
    2. Dim msgarrived As String
    3. Dim i As Integer
    4.  
    5.  
    6. Private Sub cmdconnect_Click()
    7. client(i).Connect txtip.Text, txtportnum.Text
    8. MsgBox "Connected To " & txtip.Text
    9. End Sub
    10.  
    11. Private Sub cmdsend_Click()
    12. For i = 0 To client.ubound - 1
    13.         If client(i).State = sckConnected Then
    14. client(i).SendData txtnickname.Text & ": " & txtmsg.Text
    15. txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
    16. txtmsg.Text = ""
    17.         End If
    18.    DoEvents
    19. Next i
    20.  
    21. End Sub
    22.  
    23. Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
    24.     client(i).Accept requestID
    25. End Sub
    26.  
    27. Private Sub client_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    28. Call client_Close(Index)
    29. End Sub
    30.  
    31. Private Sub client_Close(Index As Integer)
    32.     client(Index).Close
    33. End Sub

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: problems with chat program

    Why does your client have an array of winsocks?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    im not sure i will take out the array and see if it works


    VB Code:
    1. Private Sub cmdsend_Click()
    2. client(i).SendData txtnickname.Text & ": " & txtmsg.Text
    3. txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
    4. txtmsg.Text = ""
    5. End Sub

    is giving me this error when i tr to send a message

    Wrong protocol or connection for the requsted transaction or request
    Last edited by BladeZ; Jul 10th, 2005 at 05:17 PM.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: problems with chat program

    Post the full application, ie zip it up and post it.

    I dont think you completly understand what is going on. I will fix it up for you.

    Pino

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    k here it is just dont mind the look of it as its not final as soon as it works im adding lots more features

    !!!EDIT!!! uh just to let you know the tutorial i used from here was from

    http://www.ddrheaven.com/Tutorials/vb.asp
    Attached Files Attached Files

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    redid the entire thing from scratch so it looks better hope you can still help though
    Attached Files Attached Files

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: problems with chat program

    whats the problem it works fine ?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    well ok here it goes i started your tutorial alkl over again and im trying to get it multi-client so i was wondering if you could help me with what code goes were and such stuff
    Last edited by BladeZ; Jul 12th, 2005 at 05:05 PM.

  11. #11
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: problems with chat program

    oo multi user i'll look into it for you

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: problems with chat program

    k thanks and i think it would help alo of people if you make a guide like you did for the normal chat

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