Click here to Skip to main content
16,005,169 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: help me plz Pin
Nilesh Hapse24-Jul-07 1:57
Nilesh Hapse24-Jul-07 1:57 
AnswerHow many times do we have to tell you?!? Pin
leckey24-Jul-07 3:00
leckey24-Jul-07 3:00 
GeneralRe: How many times do we have to tell you?!? Pin
magedhv24-Jul-07 3:03
magedhv24-Jul-07 3:03 
Questioncall function Pin
Tom Deketelaere24-Jul-07 0:38
professionalTom Deketelaere24-Jul-07 0:38 
QuestionRip CD options Pin
ianbacalla24-Jul-07 0:29
ianbacalla24-Jul-07 0:29 
QuestionAuto generate Label and Text box on Page Load Pin
fmlove24-Jul-07 0:07
fmlove24-Jul-07 0:07 
AnswerRe: Auto generate Label and Text box on Page Load Pin
Christian Graus24-Jul-07 0:10
protectorChristian Graus24-Jul-07 0:10 
QuestionCheck availability of SMTP server Pin
Steven J Jowett24-Jul-07 0:06
Steven J Jowett24-Jul-07 0:06 
I have the following function that checks the availability of an SMTP server.

 <br />
Private Enum SMTPResponse As Integer<br />
   CONNECT_SUCCESS = 220<br />
   GENERIC_SUCCESS = 250<br />
   DATA_SUCCESS = 354<br />
   QUIT_SUCCESS = 221<br />
End Enum<br />
<br />
<br />
Public Shared Function IsServerAvailable(ByVal Address As String) As Boolean<br />
            Try<br />
                Dim IPhst As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(Address)<br />
                Dim endPt As New System.Net.IPEndPoint(IPhst.AddressList(0), 25)<br />
                Dim socket As New System.Net.Sockets.Socket(endPt.AddressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)<br />
                socket.Connect(endPt)<br />
                If Not CheckResponse(socket, SMTPResponse.CONNECT_SUCCESS) Then<br />
                    socket.Close()<br />
                    Return False<br />
                Else<br />
                    Return True<br />
                End If<br />
            Catch<br />
                Return False<br />
            End Try<br />
        End Function<br />
<br />
Private Shared Function CheckResponse(ByVal Socket As System.Net.Sockets.Socket, ByVal ExpectedResponse As SMTPResponse) As Boolean<br />
            Dim sResponse As String<br />
            Dim iResponse As Integer<br />
            Dim bytes(1024) As Byte<br />
<br />
            While Socket.Available = 0<br />
                System.Threading.Thread.Sleep(100)<br />
            End While<br />
<br />
            Socket.Receive(bytes, 0, Socket.Available, Net.Sockets.SocketFlags.None)<br />
            sResponse = System.Text.Encoding.ASCII.GetString(bytes)<br />
            iResponse = Convert.ToInt32(sResponse.Substring(0, 3))<br />
            If iResponse <> CType(ExpectedResponse, Integer) Then<br />
                Return False<br />
            Else<br />
                Return True<br />
            End If<br />
        End Function<br />


The problem is, it always returns false with the error :-

No connection could be made because the target machine actively refused it

Any assistance of resolving this problem, would be gratefully received.

Thanks

Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'

AnswerRe: Check availability of SMTP server Pin
Craster24-Jul-07 3:39
Craster24-Jul-07 3:39 
GeneralRe: Check availability of SMTP server Pin
Steven J Jowett24-Jul-07 5:41
Steven J Jowett24-Jul-07 5:41 
GeneralRe: Check availability of SMTP server Pin
Craster24-Jul-07 5:51
Craster24-Jul-07 5:51 
GeneralRe: Check availability of SMTP server Pin
Steven J Jowett25-Jul-07 5:26
Steven J Jowett25-Jul-07 5:26 
QuestionDisableVisualStyles Pin
Tom Deketelaere23-Jul-07 23:58
professionalTom Deketelaere23-Jul-07 23:58 
AnswerRe: DisableVisualStyles Pin
Luc Pattyn24-Jul-07 2:19
sitebuilderLuc Pattyn24-Jul-07 2:19 
GeneralRe: DisableVisualStyles Pin
Tom Deketelaere24-Jul-07 3:11
professionalTom Deketelaere24-Jul-07 3:11 
GeneralRe: DisableVisualStyles Pin
Luc Pattyn24-Jul-07 4:00
sitebuilderLuc Pattyn24-Jul-07 4:00 
GeneralRe: DisableVisualStyles Pin
Tom Deketelaere24-Jul-07 4:23
professionalTom Deketelaere24-Jul-07 4:23 
QuestionVariable Declaration Clarifications (Newbie) Pin
frankiebaby223-Jul-07 22:40
frankiebaby223-Jul-07 22:40 
AnswerRe: Variable Declaration Clarifications (Newbie) Pin
Christian Graus23-Jul-07 23:25
protectorChristian Graus23-Jul-07 23:25 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Colin Angus Mackay23-Jul-07 23:39
Colin Angus Mackay23-Jul-07 23:39 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Christian Graus23-Jul-07 23:42
protectorChristian Graus23-Jul-07 23:42 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Colin Angus Mackay24-Jul-07 0:38
Colin Angus Mackay24-Jul-07 0:38 
JokeRe: Variable Declaration Clarifications (Newbie) Pin
Luc Pattyn24-Jul-07 2:22
sitebuilderLuc Pattyn24-Jul-07 2:22 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
frankiebaby224-Jul-07 0:19
frankiebaby224-Jul-07 0:19 
AnswerRe: Variable Declaration Clarifications (Newbie) Pin
Dave Kreskowiak24-Jul-07 4:16
mveDave Kreskowiak24-Jul-07 4:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.