Hey there people,
I got an serieus problem with my program (ofcourse otherwise i should not post it here).
I am making a multi client server with winsock2005.dll.
i got it all working including events of all the clients.
Those events all work BUT.....
there is problem ofcourse.
The problem is that i want the data that is recieved to showup in some sort of control (doenst matter what. Textbox,listbox,form.text, whatever).
But this dont work.
When i put the value that is gathered form the event i can show it in a msgbox or place it in the console. I can put it into a public variable in the form and show that in a msgbox or in the console but i cant get that value(wich is a string) into any of the controls on my form.
Here some of my code:
Form:
Here the code of the connection request event in my "server" class:
And here my code of the "client" class:
As you see in the comment of the code i cant even acces the form1 controls when this client is made.
As you see i tried to invoke the data but even that dont work.
I realy hope someone can help with this problem.
Gegroet
I got an serieus problem with my program (ofcourse otherwise i should not post it here).
I am making a multi client server with winsock2005.dll.
i got it all working including events of all the clients.
Those events all work BUT.....
there is problem ofcourse.
The problem is that i want the data that is recieved to showup in some sort of control (doenst matter what. Textbox,listbox,form.text, whatever).
But this dont work.
When i put the value that is gathered form the event i can show it in a msgbox or place it in the console. I can put it into a public variable in the form and show that in a msgbox or in the console but i cant get that value(wich is a string) into any of the controls on my form.
Here some of my code:
Form:
VB.NET:
Public str1 As String
Dim serv As Server
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
serv = New Server()
serv.start_server(9000)
Me.lstClients.Items.Add("okok")
End Sub
Here the code of the connection request event in my "server" class:
VB.NET:
Private Sub pendingConnection(ByVal sender As Object, ByVal e As WinsockClientReceivedEventArgs) Handles ServerSocket.ConnectionRequest
Console.WriteLine("test")
Dim x As New Winsock2005DLL.Winsock()
x.Accept(e.Client)
'
tClient = New Client(x)
' "
Clients.add(tClient)
' tClient.wClient.Send("aloa")
End Sub
And here my code of the "client" class:
VB.NET:
Public wClient As Winsock2005DLL.Winsock
Public naam As String
Dim tstring As String
Delegate Sub SetTextCallback(ByVal sender As Object, ByVal e As WinsockDataArrivalEventArgs)
Public Sub New(ByVal sock As Winsock)
wClient = sock
''''' even this code dont work, it wont give errors but just dont do anything.
Form1.lstClients.Items.Add(naam)
Form1.lstClients.Items.Add("okok")
''''''
AddHandler wClient.DataArrival, AddressOf data_arrivel
AddHandler wClient.Disconnected, AddressOf client_disconnected
End Sub
Private Sub data_arrivel(ByVal sender As Object, ByVal e As WinsockDataArrivalEventArgs)
'MsgBox("bla bla")
wClient.Get(tstring)
Console.WriteLine(tstring)
Form1.Text = "mongool"
If Form1.lstData.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf data_arrivel)
Form1.lstData.Invoke(d, New Object() {tstring})
Else
Form1.lstData.Items.Add(tstring)
End If
End Sub
As you see in the comment of the code i cant even acces the form1 controls when this client is made.
As you see i tried to invoke the data but even that dont work.
I realy hope someone can help with this problem.
Gegroet