problema con vb net e system.net.socket

F

Fabio Cirillo

Ragazzi,
leggevo su masterdrive di questo codice che in c# funziona benissimo
mentre se convertito in VB (come sotto) si blocca o, se funziona, riceve
la risposta dal server whois dopo un infinità di tempo. Possibile che il
c# funzioni meglio del VB ? Ma il codice non viene compilato in CLR ?

public function checkDomain(strDomain as String, extDomain as String)
try
'connessione all host
dim objTcp as TcpClient = new TcpClient("whois.nic.it", 43)
dim domain as string = strDomain + "." + extDomain + "\r\n"
dim arrDomain as byte() = Encoding.ASCII.GetBytes(domain)
'invio della richiesta e attesa della risposta
dim ObjStream as Stream = objTcp.GetStream()
ObjStream.Write(arrDomain, 0, domain.Length)
dim objSr as StreamReader = new
StreamReader(objTcp.GetStream(), Encoding.ASCII)
'registro la risposta
dim result as string =
Regex.Replace(objSr.ReadToEnd(),"\n","<br>")
'controllo l'esistenza
if result.IndexOf("No entries found") <> -1 then
return "dominio disponibile"
else
return "dominio non disponibile"
end if
objTcp.Close()
catch e as exception
return e.ToString()
end try
end function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,037
Latest member
MozzGuardBugs

Latest Threads

Top