23/03/08 20:53
Tiddiò
Salve a tutti. Espongo il mio problema
Stò facendo una chat semplice semplice formata ovviamente da client e server.
Una volta compilati sia il client che il server li provo con l'ip utilizzato per chattare con il proprio computer e fino a qui tutto ok, quando lo vado a dare ad un amico non funziona, perchè?
Avevo pensato che la porta che sfrutta la mia chat fosse chiusa, ma non può essere perchè ho provato ad aprirla e comunque il client non vede il server e viceversa.
Quasi sempre all'amico a cui passo il server o il client non parte proprio il programma dando un'errore.
Potete perfavore guardare i miei codici? Se non trovate niente mi potete fornire un tutorial?
Questo è il server0:
Questo il client:
Questi codici li ho presi da una guida ecco perchè mi sembra strano che siano sbagliati, ma comunque tutto può essere
Stò facendo una chat semplice semplice formata ovviamente da client e server.
Una volta compilati sia il client che il server li provo con l'ip utilizzato per chattare con il proprio computer e fino a qui tutto ok, quando lo vado a dare ad un amico non funziona, perchè?
Avevo pensato che la porta che sfrutta la mia chat fosse chiusa, ma non può essere perchè ho provato ad aprirla e comunque il client non vede il server e viceversa.
Quasi sempre all'amico a cui passo il server o il client non parte proprio il programma dando un'errore.
Potete perfavore guardare i miei codici? Se non trovate niente mi potete fornire un tutorial?
Questo è il server0:
Option Explicit 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) If (wskServer.State <> sckClosed) Then wskServer.Close wskServer.Accept requestID txtReply.Text = txtReply.Text & "Connessione accettata..." & vbCrLf txtReply.SelStart = Len(txtReply.Text) 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 wskServer.SendData txtOut.Text & vbCrLf End Sub
Questo il client:
Option Explicit Public Sub Connetti_Click() txtReply.Text = txtReply.Text & "Connessione in corso..." txtReply.SelStart = Len(txtReply.Text) wskClient.Close wskClient.LocalPort = 0 wskClient.Connect txtHostName.Text, 2000 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" txtReply.SelStart = Len(txtReply.Text) Exit Sub End If wskClient.SendData txtOut.Text & vbCrLf End Sub
Questi codici li ho presi da una guida ecco perchè mi sembra strano che siano sbagliati, ma comunque tutto può essere
Ultima modifica effettuata da Tiddiò 23/03/08 21:35
aaa