🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #15

[VB2008] riconoscere disconnessione di un client

#15
From: Me Stesso
Date: Sat, 30 Aug 2008 10:02
44 lines
2461 bytes
Ho un grossso problema che non riesco proprio a risolvere. E' tutto il 
giorno che smanetto ma non ne vengo a capo ed in oltre ho notato che molti 
hanno lo stesso mio problema.

Avendo un server che legge dati da un client, non riesco a fare in modo che 
il server riconosca quando il client si disconnette.

Vi spiego meglio che cosa succede:
1. Apro il client, mi connetto al server ed invio i dati tranquillamente ed 
il server li riceve dando risposta.
2. Chiudo il client.
3. Apro di nuovo il client, mi riconetto allo stesso server, invio i dati ma 
il server questa volta non li riceve e non da nessuna risposta.

Io vorrei che quando riapro il client e mi riconnetto al server, sia 
possibile inviare di nuovo i dati.

Come posso risolvere questo problema?


Vi riporto parte di codice del server per mostrarvi come sta funzinando:

codice della sub main:
tcpListen As New TcpListener(ip, porta)
tcpListen.Start()
tcpClient = tcpListen.AcceptTcpClient()
netStream = tcpClient.GetStream()

If tcpClient.Connected = True Then
Timer1.Enabled = True
End If


e questo � il codice nel timer:

[code]
If netStream.DataAvailable = True Then
Dim comando As String
Dim dato(tcpClient.ReceiveBufferSize()) As Byte

netStream.Read(dato, 0, dato.Length)

end if
[/code]
Technical Details
Message-ID: <48b91abf$0$18149$4fafbaef@reader3.news.tin.it>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!feeder.news.tin.it!spool.news.tin.it!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,3e92ac6ea1a8d2ca,start
X-Google-Attributes: gidf94ee,domainid0,public,usenet
X-Google-Language: ITALIAN,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!feeder.news.tin.it!spool.news.tin.it!not-for-mail
From: "Me Stesso" <no@spam.grazie>
Newsgroups: free.it.visual-basic
Subject: [VB2008] riconoscere disconnessione di un client
Date: Sat, 30 Aug 2008 12:02:38 +0200
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=original
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16386
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16386
Lines: 49
Message-ID: <48b91abf$0$18149$4fafbaef@reader3.news.tin.it>
Organization: TIN.IT (http://www.tin.it)
X-Comments: Please send technical notifications to newsmaster@tin.it
NNTP-Posting-Host: 87.8.209.142
X-Trace: 1220090559 reader3.news.tin.it 18149 87.8.209.142:2457
X-Complaints-To: Please send abuse reports to abuse@retail.telecomitalia.it