Click here to Skip to main content
15,914,780 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: The virtual path '/Templates/mysite/Main.master' maps to another application, which is not allowed Pin
Not Active21-Oct-09 4:07
mentorNot Active21-Oct-09 4:07 
QuestionOle DB command not working Pin
W4Rl0CK4720-Oct-09 10:00
W4Rl0CK4720-Oct-09 10:00 
QuestionProblems with VB6 Winsock connection and Senddata Pin
she-Developer20-Oct-09 4:58
she-Developer20-Oct-09 4:58 
AnswerRe: Problems with VB6 Winsock connection and Senddata Pin
dan!sh 20-Oct-09 7:20
professional dan!sh 20-Oct-09 7:20 
AnswerRe: Problems with VB6 Winsock connection and Senddata Pin
Eddy Vluggen20-Oct-09 10:50
professionalEddy Vluggen20-Oct-09 10:50 
GeneralRe: Problems with VB6 Winsock connection and Senddata Pin
she-Developer20-Oct-09 21:40
she-Developer20-Oct-09 21:40 
GeneralRe: Problems with VB6 Winsock connection and Senddata Pin
Eddy Vluggen20-Oct-09 22:45
professionalEddy Vluggen20-Oct-09 22:45 
AnswerRe: Problems with VB6 Winsock connection and Senddata [modified] Pin
MatthysDT21-Oct-09 20:33
MatthysDT21-Oct-09 20:33 
I just had a look of some of my own code and found that every time, before I connect I follow the following logic:
(I cut out alot of irrelevant code such as error handling etc. so I may have made a mistake somewhere but you should get the general idea)

Sub AttemptConnectionToRemoteHost()
'(wsh is my client winsock control)

    If wsh.State <> sckClosed Then
        wsh.Close
    End If
   
    wsh.RemoteHost = RTrim(LTrim(txtAddress))
    wsh.RemotePort = CLng(txtPort)
    
    wsh.Connect
    Await()
    If wsh.State = sckConnected Then
       'Report success!!
    Else
       'Report Failure
    End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Await()
'Allow x seconds to for connection
Dim x As Long
Dim EndTime As Single
    x = CLng(5) 'Allow 5 seconds for connection attempt
    EndTime = Timer + x
    Do
        DoEvents
    Loop While (wsh.State <> sckConnected) And (EndTime > Timer)

End Sub


This should do the trick for you. I found that, always checking that the port's state is sckConnected, before attempting anything with it, is a good failsafe. Use the Await() procedure above to ensure that the port is CONNECTED before continuing. You could bring the 5 seconds down to as little as 1 second for local LAN applications.


modified on Thursday, October 22, 2009 2:39 AM

QuestionProblem serializing to SOAP when using System.Object [modified] Pin
annathor20-Oct-09 1:36
annathor20-Oct-09 1:36 
QuestionInterop Questions Pin
#realJSOP20-Oct-09 1:02
professional#realJSOP20-Oct-09 1:02 
AnswerRe: Interop Questions Pin
NormDroid20-Oct-09 1:35
professionalNormDroid20-Oct-09 1:35 
GeneralRe: Interop Questions Pin
#realJSOP20-Oct-09 3:49
professional#realJSOP20-Oct-09 3:49 
AnswerRe: Interop Questions Pin
freakyit20-Oct-09 1:35
freakyit20-Oct-09 1:35 
AnswerRe: Interop Questions Pin
Richard MacCutchan20-Oct-09 1:36
mveRichard MacCutchan20-Oct-09 1:36 
QuestionOracle 10 g user id passwords Pin
manish.m.meshram19-Oct-09 18:30
manish.m.meshram19-Oct-09 18:30 
QuestionHow to get Default Mail Application name? (like microsoft office outlook) Pin
CeremBeyazit19-Oct-09 12:39
CeremBeyazit19-Oct-09 12:39 
AnswerRe: How to get Default Mail Application name? (like microsoft office outlook) Pin
N a v a n e e t h19-Oct-09 16:40
N a v a n e e t h19-Oct-09 16:40 
QuestionUnusual Problem: Listbox Not Updating Pin
raineym19-Oct-09 7:50
raineym19-Oct-09 7:50 
AnswerRe: Unusual Problem: Listbox Not Updating Pin
Luc Pattyn19-Oct-09 7:57
sitebuilderLuc Pattyn19-Oct-09 7:57 
GeneralRe: Unusual Problem: Listbox Not Updating [modified] Pin
raineym19-Oct-09 8:52
raineym19-Oct-09 8:52 
GeneralRe: Unusual Problem: Listbox Not Updating Pin
Luc Pattyn19-Oct-09 9:11
sitebuilderLuc Pattyn19-Oct-09 9:11 
GeneralRe: Unusual Problem: Listbox Not Updating Pin
raineym19-Oct-09 10:34
raineym19-Oct-09 10:34 
GeneralRe: Unusual Problem: Listbox Not Updating Pin
Luc Pattyn19-Oct-09 10:38
sitebuilderLuc Pattyn19-Oct-09 10:38 
NewsVisual Studio Beta 2 Available This Week, VS 2010 Launch Date Announced, New Packaging Revealed Pin
brucedkyle19-Oct-09 6:24
brucedkyle19-Oct-09 6:24 
QuestionCapture Screenshot of a Window(With Handle) Pin
Harrison Jones19-Oct-09 6:17
Harrison Jones19-Oct-09 6:17 

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.