|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Feb 2009
Messaggi: 212
|
[Visual Basic 6] Chat con Winsock, aiuto!!!
Chat con winsock, aiuto!!
-------------------------------------------------------------------------------- Salve a tutti, sto facendo una chat molto semplice con winsock, sinteticamente ho una parte client e una parte server, il server ascolta il canale, il client si connette a quel canale e i due computer comunicano fra loro, si possono inviare messaggi. Il quesito è: come inviare e ricevere veri e propri files??? insomma mi servirebbe un tasto sfoglia per selezionare il file da inviare, e fin qui ci sono, basta inserire un commondialog... L'open...solo che non so più andare avanti, non so come inviare questo file che ho scelto, non so come aprirlo, selezionarlo ne niente. So solo come aprire la finestra Sfoglia. Potete aiutarmi? vi posto il sorgente. Grazie mille a tutti!! PROGRAMMA CLIENT Private Sub Form_Load() txtChat.Text = "" txtInvia.Text = "" End Sub Private Sub TCP_Connect() lblStato.Caption = "Connesso" End Sub Private Sub btnDisconnetti_Click() btnConnetti.Enabled = True TCP.Close End Sub Private Sub TCP_Close() TCP.Close lblStato.Caption = "Disconnesso" End Sub Private Sub btnInvia_Click() TCP.SendData txtInvia.Text txtChat.Text = txtChat.Text & "Io: " & txtInvia.Text & vbCrLf txtChat.SelStart = Len(txtChat.Text) txtInvia.Text = vbNullString End Sub Private Sub TCP_DataArrival(ByVal bytesTotal As Long) Dim Data As String TCP.GetData Data txtChat.Text = txtChat.Text & "Server: " & Data & vbCrLf txtChat.SelStart = Len(txtChat.Text) End Sub Private Sub TCP_SendComplete() lblStato.Caption = "Dati inviati" End Sub ---------------------------------------------------------- PROGRAMMA SERVER Private Sub Form_Load() txtChat.Text = "" txtInvia.Text = "" End Sub Private Sub TCP_Close() TCP.Close lblStato.Caption = "Disconnesso" End Sub Private Sub btnAscolta_Click() Static Connesso As Boolean If Connesso = False Then TCP.LocalPort = Val(txtPorta.Text) TCP.Listen btnAscolta.Caption = "Disconnetti" Connesso = True lblStato.Caption = "In ascolto" Else TCP.Close Connesso = False btnAscolta.Caption = "Ascolta" lblStato.Caption = "Disconnesso" End If End Sub Private Sub btnInvia_Click() TCP.SendData txtInvia.Text txtChat.Text = txtChat.Text & "Io: " & txtInvia.Text & vbCrLf txtChat.SelStart = Len(txtChat.Text) txtInvia.Text = vbNullString End Sub Private Sub TCP_DataArrival(ByVal bytesTotal As Long) Dim Data As String TCP.GetData Data txtChat.Text = txtChat.Text & "Client: " & Data & vbCrLf txtChat.SelStart = Len(txtChat.Text) End Sub Private Sub TCP_SendComplete() lblStato.Caption = "Dati inviati" End Sub Private Sub TCP_ConnectionRequest(ByVal requestID As Long) lblStato.Caption = "Richiesta di connessione" If MsgBox("Accettare la connessione?", vbYesNo) = vbYes Then TCP.Close TCP.Accept requestID lblStato.Caption = "Connesso" Else TCP.Close TCP.LocalPort = Val(txtPorta.Text) TCP.Listen End If End Sub ------------------------------------------------------------- Penso si capisca che oggetti ho usato nel form, se non è chiaro posso spiegare!!! Grazie di ogni eventuale aiuto!!! |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3210
|
Sul web c'è una marea di informazioni e codice sui Winsock di VB6.
Inizierei da freevbcode.com che spesso è ricco di spunti pratici. Qui c'è già un progetto pronto per il file transfer: http://www.freevbcode.com/ShowCode.asp?ID=988 ![]() |
![]() |
![]() |
![]() |
#3 | |
Member
Iscritto dal: Feb 2009
Messaggi: 212
|
Quote:
Comunque grazie!!! Sei grande, è proprio ciò che mi serviva!!! |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:45.