winsock help
winsock help
winsock help
winsock help
winsock help
winsock help winsock help winsock help winsock help winsock help winsock help winsock help winsock help
winsock help winsock help
winsock help
Go Back  Xtreme Visual Basic Talk > > > winsock help


Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2004, 02:48 PM
14yrsgirl 14yrsgirl is offline
Junior Contributor
 
Join Date: Dec 2003
Posts: 226
Default winsock help


when running my program using winsock it works great if the host is already listening but if the client end trys to connect first before the host is listening then it wont connect obviously. how can i do some kind of loop to see if the host is listening or not ?

thank you.
casey.
Reply With Quote
  #2  
Old 12-21-2004, 03:04 PM
William_Cain's Avatar
William_Cain William_Cain is offline
Junior Contributor
 
Join Date: Jul 2004
Location: Norway
Posts: 318
Default

Use UDP.

Client: Sends out his IP at 255.255.255.255:xxxx.
Server: If online, answers with his IP directly back at the client's IP.
Client: If server replies, it's online. If not, it's offline. You'll also get the IP of the server this way, so that the client is released of the stress it is to type in the IP of the server.
Client: Connects to server using the newly acquired IP.
Reply With Quote
  #3  
Old 12-21-2004, 03:18 PM
14yrsgirl 14yrsgirl is offline
Junior Contributor
 
Join Date: Dec 2003
Posts: 226
Default

thanks for the reply but its not what i was looking for though a good idea about not typing out the ip, i came up with this but was wondering if there was a better way.
Code:
Do Winsock1.Close Winsock1.Connect host, port DoEvents If Winsock1.State = sckConnected Then Exit Do End If Sleep 1000 Loop

thank you.
casey.
Reply With Quote
  #4  
Old 12-23-2004, 08:13 PM
kill4 kill4 is offline
Freshman
 
Join Date: Dec 2004
Location: Texas
Posts: 27
Default

Try this first make sure the server isnt listening

try to connect to the server with the client in the Winsock1_Error Sub put this code


Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

MsgBox Description

End Sub

See what error you get back and what ever you get back is becuz the server isnt listening and maybe you could try to make it loop from there until the error = false that means more then likely its connected now cuz no errors have returned hope this helps if you dont get what i mean post again and il try to explain it better
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
winsock help
winsock help
winsock help winsock help
winsock help
winsock help
winsock help winsock help winsock help winsock help winsock help winsock help winsock help
winsock help
winsock help
 
winsock help
winsock help
 
-->