-
May 7th, 2012, 04:53 AM
#1
Thread Starter
New Member
loop attemp connect on the client computer
'Can I change?
Private Sub Form_Load()
Winsock1.Connect "192.168.1.1", "55501"
End Sub
'To this one?
Private Sub Form_Load()
Do
Winsock1.Connect "192.168.1.1", "55501"
Loop Until (Winsock1.State = sckConnected)
End Sub
tried it but i get and invalid operation at current state...
just made a client sever program where the client sends a message to server when computer boots up... that's if the server computer boots up first... but when the client computer boots first server computer wont be able to gain connection to client computer anymore until client computer reboots..
please any help would be much appreciated....
-
May 7th, 2012, 04:58 AM
#2
Re: loop attemp connect on the client computer
That looks like VB6 code. Are you sure that you're using VB.NET?
-
May 7th, 2012, 05:08 AM
#3
Thread Starter
New Member
Re: loop attemp connect on the client computer
oops, sorry, i thought i was in VB6 forums.... but any way can you still help me with that? or i'll have to repost to vb6 forum again? sorry for me being a noob...
-
May 7th, 2012, 05:14 AM
#4
Re: loop attemp connect on the client computer
I'll ask the mods to move this thread to the correct forum. Please don't repost.
-
May 7th, 2012, 05:22 AM
#5
Thread Starter
New Member
Re: loop attemp connect on the client computer
thanks a lot, hope to get more replies....
-
May 7th, 2012, 05:31 AM
#6
Re: loop attemp connect on the client computer
Welcome to VBForums
Thread moved from the 'VB.Net' (VB2002 and later) forum to the 'VB6 and Earlier' forum
(thanks for letting us know jmcilhinney )
-
May 7th, 2012, 06:40 AM
#7
Re: loop attemp connect on the client computer
looks like you need some delay, to stop the code from looping, until the connection attempt times out
or better look into the events of the winsock control
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 7th, 2012, 08:38 PM
#8
Thread Starter
New Member
Re: loop attemp connect on the client computer
tnx for the reply West, honestly i'm not good at coding, can you please give a sample code for me to get a start off? or just the right coding for this one?
Private Sub Form_Load()
Do
Winsock1.Connect "192.168.1.1", "55501"
Loop Until (Winsock1.State = sckConnected)
End Sub
tnx in advance...
-
May 7th, 2012, 11:04 PM
#9
Thread Starter
New Member
Re: loop attemp connect on the client computer
ok guys, i,ve figured it out...
Tnx west for the tip...just want to share it...^_^
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
label1.Caption = label1.Caption - 1
If label1.Caption = 0 Then
label1.Caption = 2
If Winsock1.State <> sckConnected Then
Winsock1.Close
Winsock1.Connect "192.168.254.11", "55501"
Else
Timer1.Enabled = False
End If
End If
End Sub
I think this code is not bad for a week watching coding tutorials eh? ^_^
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|