Hi, I'm really new to vb.net, but I think I understand the remoting tools, I can create a class on the server, the client connect to it and execute some function on the server. But how the server can talk to the client? I was thinking with some kind of raise event but i'm not sure.
My vision is simple, I'll have many client connecting to the server, like 200 clients, they will communicate with the server with all the Class I'll made, but I need to "push" some information to a client from a server, and I need only one client receive the event... so it's there any way we can "store" the class for each client on a kind of array for the server can use it later for send a "event" to a specific client?
Or maybe the remoting tools are not what I need to use in that situation?
Thank you very much
Jean-Francois Dionne
on the client declare a TcpClient
Private Const READ_BUFFER_SIZE As Integer = 255
Private client As TcpClient
Private readBuffer(READ_BUFFER_SIZ
on Loadform
client = New TcpClient(HOST_IP, PORT_NUM)
' Start an asynchronous read invoking DoRead to avoid lagging the user interface.
client.GetStream.BeginRead
''' <summary>
''' This is the callback function for TcpClient.GetStream.Begin to get an asynchronous read.
''' </summary>
''' <param name="ar"></param>
''' <remarks></remarks>
Private Sub DoRead(ByVal ar As IAsyncResult)
Dim BytesRead As Integer = -1
Dim strMessage As String = ""
Try
' Finish asynchronous read into readBuffer and return number of bytes read.
BytesRead = client.GetStream.EndRead(a
If BytesRead < 1 Then
Exit Sub 'If no bytes were read server has close.
Else
' Convert the byte array the message was saved into, minus two for the Chr(13) and Chr(10)
strMessage = Encoding.ASCII.GetString(r
ProcessCommands(strMessage
' Start a new asynchronous read into readBuffer.
client.GetStream.BeginRead
End If
Catch e As Exception
End Try
BytesRead = Nothing : strMessage = Nothing
End Sub