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:
Private Sub cmdsend_Click()
For i = 0 To server.ubound - 1
If client(i).State = sckConnected Then
client(i).SendData txtnickname.Text & ": " & txtmsg.Text
End If
DoEvents
Next i
txtchat.Text = txtchat.Text & txtnickname.Text & ": " & txtmsg.Text & vbNewLine
txtmsg.Text = ""
End Sub
VB Code:
Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
client(i).GetData msgarrived, vbString
txtchat.Text = txtchat.Text & msgarrived & vbNewLine
End Sub
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:
Private Sub cmdsend_Click()
For i = 0 To server.ubound - 1
If client(i).State = sckConnected Then
client(i).SendData txtnickname.Text & ": " & txtmsg.Text
End If
DoEvents
Next i
txtchat.Text = txtchat.Text & txtnickname.Text & ": " & txtmsg.Text & vbNewLine
txtmsg.Text = ""
End Sub
VB Code:
Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
client(i).GetData msgarrived, vbString
txtchat.Text = txtchat.Text & msgarrived & vbNewLine
End Sub
post your app for me :)
Re: problems with chat program
Server
VB Code:
Option Explicit
Dim msgarrived As String
Dim i As Integer
Private Sub cmdsend_Click()
For i = 0 To server.ubound - 1
If server(i).State = sckConnected Then
server(i).SendData txtnickname.Text & ": " & txtmsg.Text
End If
DoEvents
Next i
txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
txtmsg.Text = ""
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Dim newClient As Long
If Index = 0 Then
'this is the listening server
'load a new control to talk to this client
newClient = LoadNextServer(server)
server(newClient).Accept requestID
server(newClient).SendData "Hello: you are connected"
End If
End Sub
Private Sub server_DataArrival(Index As Integer, ByVal bytesTotal As Long)
txtchat.Text = msgarrived & vbNewLine
End Sub
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)
Call server_Close(Index)
End Sub
Private Sub server_Close(Index As Integer)
server(Index).Close
Unload server(Index)
End Sub
Function LoadNextServer(wsServer) As Long
Dim wsck
Dim i As Long
i = 0
For Each wsck In wsServer
If wsck.Index > i Then
LoadNextServer = i
Load wsServer(i)
Exit Function
Else
i = i + 1
End If
Next
LoadNextServer = i
Load wsServer(i)
End Function
Client
VB Code:
Option Explicit
Dim msgarrived As String
Dim i As Integer
Private Sub cmdconnect_Click()
client(i).Connect txtip.Text, txtportnum.Text
MsgBox "Connected To " & txtip.Text
End Sub
Private Sub cmdsend_Click()
For i = 0 To client.ubound - 1
If client(i).State = sckConnected Then
client(i).SendData txtnickname.Text & ": " & txtmsg.Text
txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
txtmsg.Text = ""
End If
DoEvents
Next i
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
client(i).Accept requestID
End Sub
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)
Call client_Close(Index)
End Sub
Private Sub client_Close(Index As Integer)
client(Index).Close
End Sub
Re: problems with chat program
Why does your client have an array of winsocks?
Re: problems with chat program
im not sure i will take out the array and see if it works
VB Code:
Private Sub cmdsend_Click()
client(i).SendData txtnickname.Text & ": " & txtmsg.Text
txtchat.Text = txtnickname.Text & ": " & txtmsg.Text & vbNewLine
txtmsg.Text = ""
End Sub
is giving me this error when i tr to send a message
Wrong protocol or connection for the requsted transaction or request
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
1 Attachment(s)
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
1 Attachment(s)
Re: problems with chat program
redid the entire thing from scratch so it looks better hope you can still help though
Re: problems with chat program
whats the problem it works fine :lol:?
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
Re: problems with chat program
oo multi user :) i'll look into it for you
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