 |
 |

06-20-2003, 07:24 PM
|
|
Freshman
|
|
Join Date: Jun 2003
Posts: 29
|
|
winsock connecting state, loop
|
Private Sub mnuFileConnect_Click()
On Error Resume Next
Dim iServ As String
iServ = "ipnumber"
If iServ = "" Then Exit Sub
'Disable menus
frmMain.mnuFileConnect.Enabled = False
frmMain.mnuFileExit.Enabled = False
'Connect to the server
With wsk
.Close
.Protocol = sckTCPProtocol
.RemotePort = ServerPort
.RemoteHost = iServ
.Connect
End With
Call ShowText("Connecting to server" & vbCrLf & vbCrLf)
StatusBar2.Panels(1).Text = "Status: Connecting"
End Sub
----------------------------------
THIS IS PART OF THE SUB i took from my game, the connecting part.. can sombody please modify it, to check the connection state and make it write it to the statusbar,, and also if winsock state is 0, not connected.. then it will keep on trying to connect.. the problem with my code is.. if the server aint up.. u have to keep reconnecting, because it dont like loop... please help
|
|

06-20-2003, 08:05 PM
|
|
Freshman
|
|
Join Date: Jun 2003
Posts: 29
|
|
help
|
If Winsock1.State = 0 Then StatusBar2.Panels(1).Text = "Closed"
If Winsock1.State = 1 Then StatusBar2.Panels(1).Text = "Open"
If Winsock1.State = 2 Then StatusBar2.Panels(1).Text = "Listening"
If Winsock1.State = 3 Then StatusBar2.Panels(1).Text = "Pending"
If Winsock1.State = 4 Then StatusBar2.Panels(1).Text = "Resolving"
If Winsock1.State = 5 Then StatusBar2.Panels(1).Text = "Resolved"
If Winsock1.State = 6 Then StatusBar2.Panels(1).Text = "Connecting"
If Winsock1.State = 7 Then StatusBar2.Panels(1).Text = "Connected"
If Winsock1.State = 8 Then StatusBar2.Panels(1).Text = "Closing"
If Winsock1.State = 9 Then StatusBar2.Panels(1).Text = "Error"
perhaps this will help people write me out a better sub
|
|

06-21-2003, 03:21 AM
|
|
Restricted
|
|
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
|
|
|
hey, erm well its against posting guidline to write the code for you, try asking a pesific question
|
|

06-21-2003, 07:33 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
Is that a specific question or a pacific question?
Sorry, couldn't resist. 
|
__________________
A wise one man once said "what you talking about dog breath"
|

06-23-2003, 04:15 PM
|
 |
Ultimate Contributor
* Expert *
|
|
Join Date: Jun 2003
Location: New York, NY
Posts: 1,929
|
|
if it doesn't loop automatically, you need to write you own loop. Don't forget to include a time-out, or you could loop indefinately. Like this:
Code:
LastTime=Now
Do
Call AttemptConnection
Loop Until (wsk.state=sckConnected) or (TimeSince(LastTime)>Timeout)
Of course, you need to define the AttemptConnection sub and the TimeSince function, and declare the Timeout value, but you get the idea...
And if your timeout value is too high, you might need a DoEvents call to continue running other controls.
|
|

06-24-2003, 03:25 PM
|
|
Freshman
|
|
Join Date: Jun 2003
Posts: 29
|
|
|
thanks to all your help guys, its sorted now
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|