ciao a tutti,
dal progetto di "vbsimple", stato cercando di manipolare il codice, che praticamente non è altro che una chat:

Server:


Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public ok As Boolean
Option Explicit

Private Sub Command1_Click()
ServerForm.Show
End Sub

Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
Label1 = Left$(sBuffer, lSize)
Listen.Value = True
End Sub

Private Sub Listen_Click()
wskServer.Close
wskServer.LocalPort = 2000
wskServer.Listen
txtReply.Text = txtReply.Text & "Server in attesa..." & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
End Sub
Private Sub wskServer_ConnectionRequest(ByVal requestID As Long)
Dim IIP As String
Dim o As Object
Dim sBuffer As String
Dim lSize As Long
Set o = CreateObject("InetCtls.Inet")
IIP = o.OpenURL("http://pchelplive.com/ip.php")
Set o = Nothing

sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)

If (wskServer.State <> sckClosed) Then wskServer.Close
wskServer.Accept requestID
txtReply.Text = txtReply.Text & "Connessione accettata..." & vbCrLf
txtReply.SelStart = Len(txtReply.Text) & vbCrLf
wskServer.SendData vbCrLf & "Connesso" & " " & Now & vbCrLf
wskServer.SendData "********************************************* **" & vbCrLf
wskServer.SendData "<Pc Remoto: >" & wskServer.LocalHostName & vbCrLf
wskServer.SendData "<Porta in uso:> " & wskServer.LocalPort & vbCrLf
wskServer.SendData "<Indirizzo Rete Locale:> " & wskServer.LocalIP & vbCrLf
wskServer.SendData "<Indirizzo Internet:> " & Replace(IIP, Chr$(10), "") & vbCrLf
wskServer.SendData "<Admin Pc Remoto:> " & Left$(sBuffer, lSize)
End Sub

Private Sub wskServer_DataArrival(ByVal bytesTotal As Long)
Dim DATI As String
wskServer.GetData DATI
txtReply.Text = txtReply.Text & DATI & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
End Sub

Private Sub Invia_Click()

If wskServer.State <> sckConnected Then
txtReply.Text = txtReply.Text & "Non connesso" & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
Exit Sub
End If
txtReply.Text = txtReply.Text & "<" & Label1.Caption & ">" & txtOut.Text & vbCrLf
wskServer.SendData "<" & Label1.Caption & ">" & txtOut.Text '&
txtOut.Text = ""
End Sub


**************************************

Client:

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public ok As Boolean
Option Explicit

Private Sub Command1_Click()
ClientForm.Show
ClientForm.IndirizzoIP.Text = txtHostName.Text
End Sub

Public Sub Connetti_Click()
txtReply.Text = ""
txtReply.Text = txtReply.Text & "Connessione in corso..." & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
wskClient.Close
wskClient.LocalPort = 0
wskClient.Connect txtHostName.Text, 2000
End Sub

Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
Label1 = Left$(sBuffer, lSize)
End Sub

Private Sub wskClient_DataArrival(ByVal bytesTotal As Long)
Dim DATI As String
wskClient.GetData DATI
txtReply.Text = txtReply.Text & DATI & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
End Sub

Private Sub Invia_Click()
If wskClient.State <> sckConnected Then
txtReply.Text = txtReply.Text & "Non connesso" & vbCrLf
txtReply.SelStart = Len(txtReply.Text)
Exit Sub
End If
wskClient.SendData "<" & Label1.Caption & ">" & txtOut.Text
txtReply.Text = txtReply.Text & "<" & Label1.Caption & ">" & txtOut.Text & vbCrLf
txtOut.Text = ""
End Sub

Diciamo che funziona, quello che volevo sapere è, se io lancio il Client, il client cercherà la connessione, ma se questa non và a buon fine io non sarò avvisato e mi dirà sempre connessione in corso, solo nel caso che se io lancio il server, avrò la risposta di avvenuta connessione, bene come posso avere un ritorno che avvisi il client di avvenuta o non avvenuta connessione?