Ciao scusate se apro un nuovo post ma proprio non riesco a venirne fuori.
Vi posto il mio problema vorrei creare un server multi conessione,pero con il codice che ho fatto riesco a conettere solo un clien alla volta e funziona bene,praticamente quando mi conetto con il secondo client il primo client non invia e riceve piu' dati,Dove sto sbagliando?
Dim data() As Byte
Dim T As Threading.Thread
Dim Client As New TcpClient
Const portNumber As Integer = 2399
Dim tcpListener As New System.Net.Sockets.TcpListener(portNumber)
Private Sub LoopInfinito()
Try
tcpListener.Start()
While True
Client = tcpListener.AcceptTcpClient
Thread.Sleep(1000)
'----------
ReDim data(Client.ReceiveBufferSize)
SendMessage("Server On Line!" & vbCrLf)
'---read from server
Client.GetStream.BeginRead(data, 0, _
CInt(Client.ReceiveBufferSize), _
AddressOf ReceiveMessage, Nothing)
End While
Catch ex As SocketException
MsgBox(ex.ToString())
Finally
Client.Close()
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
T = New Threading.Thread(AddressOf Me.LoopInfinito)
T.Start()
End Sub
Grazie per la pazienza