Aprire Microsoft Visual Basic Express, fare clic "Nuovo progetto ... " nel riquadro sinistro dello schermo , quindi selezionare " Applicazione console. " Fare clic su "OK". 
 2 Premere 
 "Ctrl " e "A ", quindi premere "Elimina" per rimuovere tutto il codice esistente . Copia e incolla il codice sottostante nel tuo " Module1.vb " per creare l'applicazione server : 
 
 Importazioni System.Net.Sockets 
 
 Imports System.Text 
 
 Module Module1 
 
 Dim hshTbl As New Hashtable 
 
Sub Main ( ) per
Dim svrSckt As New TcpListener ( 8888 ) per
 Dim TClient Come TcpClient 
 
 dim infntCntr As Integer dim 
 
 cntr As Integer 
 
svrSckt.Start ( ) per
msg ( " server avviato per la chat .... " ) per
 cntr = 0 
 
 infntCntr = 0 
 
 infntCntr = 1 To 2 
 
 infntCntr = 1 
 
 cntr + = 1 
 
TClient = svrSckt.AcceptTcpClient ( ) per
 Dim btsFrom ( 10024 ) As Byte Dim 
 
 clientData As String Dim 
 
 NetworkStream Come NetworkStream = _ 
 
tClient.GetStream ( ) per
networkStream.Read ( btsFrom , 0 , CInt ( tClient.ReceiveBufferSize ) ) per
clientData = System.Text.Encoding.ASCII.GetString ( btsFrom ) per
 clientData = _ 
 
clientData.Substring ( 0 , clientData.IndexOf ( " $ " ) ) per
 hshTbl ( clientData ) = TClient 
 
broadcast ( clientData + " ha unito " , clientData , False ) per
msg ( clientData + " ha aderito chat " ) per
 Dim client As New handleClinet 
 
client.startClient ( TClient , clientData , Sub
Programmazione © www.354353.com