"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
Go Back  Xtreme Visual Basic Talk > > > "Pinging" Problems [VB6, Winsock]


Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2005, 12:35 PM
RandomPerson333 RandomPerson333 is offline
Newcomer
 
Join Date: Dec 2005
Posts: 3
Question "Pinging" Problems [VB6, Winsock]


I've been experimenting with making a simple "messenger" program (using Winsock) and it has one error I just can't figure out--a certain timer, which is supposed to send a message to all a server's clients to check if they are still there, doesn't seem to do anything. It never sends a single message, and I can't figure out why! This is the subroutine:

[Sorry about the formatting...it won't let me put in any spaces before a line of code... ]
Private Sub PingTimer_Timer()
If NumClients >= 1 And Pinging = True Then
For w = 1 To NumClients
clientStillThere(w) = False
udpPeerA.RemoteHost = clientIPs(w) 'it's udp, in case you can't tell
udpPeerA.SendData "8749374560274365"
Next w
Pinging = False
GoTo outtathere
End If
If NumClients >= 1 And Pinging = False Then
Pinging = True
For x = 1 To NumClients
If clientStillThere(x) = False Then
If frmPeerA.WindowState = vbMinimized Then Beep
Message clientNames(x) & " has left."
For y = x To NumClients
clientIPs(y) = clientIPs(y + 1)
clientNames(y) = clientNames(y + 1)
clientStillThere(y) = clientStillThere(y + 1)
clientStatus(y) = clientStatus(y + 1)
Next y
NumClients = NumClients - 1
If NumClients > 0 Then
For zx = 1 To NumClients
udpPeerA.RemoteHost = clientIPs(zx)
udpPeerA.SendData clientNames(x) & " has left."
Next zx
End If
UpdateClientList
If NumClients = 0 Then GoTo outtathere
End If
Next x
End If
outtathere:
End Sub


(I know I could have used "else", but I took that out to see if it might not be working for some reason.)
I think most of this is self-explanatory; it is supposed to send the message on one loop, then if a response (different subroutine) isn't given by the next loop, it deletes the client from its list. (That's what that huge mess is in the second If statement. :P) The "Pinging" variable is just used to alternate what it does on each loop. The problem is, it never sends anything! There's an indicator on the form to show when a message has been recieved, but it only goes off if you type something in...if this loop were working, it would go off every 2 seconds. I have no idea what's going on here...does anyone see an error I'm not noticing?

Last edited by RandomPerson333; 12-24-2005 at 12:42 PM.
Reply With Quote
  #2  
Old 12-28-2005, 04:52 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Hi,
If you use the vb tags your code will be displayed 'properly'

Code:
Private Sub PingTimer_Timer() If NumClients >= 1 And Pinging = True Then For w = 1 To NumClients clientStillThere(w) = False udpPeerA.RemoteHost = clientIPs(w) 'it's udp, in case you can't tell udpPeerA.SendData "8749374560274365" Next w Pinging = False GoTo outtathere End If If NumClients >= 1 And Pinging = False Then Pinging = True For x = 1 To NumClients If clientStillThere(x) = False Then If frmPeerA.WindowState = vbMinimized Then Beep Message clientNames(x) & " has left." For y = x To NumClients clientIPs(y) = clientIPs(y + 1) clientNames(y) = clientNames(y + 1) clientStillThere(y) = clientStillThere(y + 1) clientStatus(y) = clientStatus(y + 1) Next y NumClients = NumClients - 1 If NumClients > 0 Then For zx = 1 To NumClients udpPeerA.RemoteHost = clientIPs(zx) udpPeerA.SendData clientNames(x) & " has left." Next zx End If UpdateClientList If NumClients = 0 Then GoTo outtathere End If Next x End If outtathere: End Sub

The most obvious question is: have you checked the value of NumClients when you enter the routine? (ie Put a Breakpoint on the first If statement and see what NumClients is)

Also, are all the arrays and variables used available to this routine ? eg are they all defined in the Declaration Section of the Form or declared as Public ?

regards
Doug
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
  #3  
Old 01-01-2006, 07:26 PM
RandomPerson333 RandomPerson333 is offline
Newcomer
 
Join Date: Dec 2005
Posts: 3
Default

Well, it checks whether NumClients is greater than 0...as long as it is, it should be fine. And yes, all the variables are declared and public.
Reply With Quote
  #4  
Old 01-02-2006, 01:00 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Hi,

My point was, if NumClients is, for some reason, zero then the code will not execute and nothing will be sent. Hence my suggestion of putting a breakpoint in to see what the actual value is. Another aid to debugging might be to put a msgbox at the start of the routine just to make sure that the timer is triggering. eg MsgBox "Timer Triggered".
This way you can eliminate one by one the possible causes.

Regards
Doug
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
  #5  
Old 01-06-2006, 09:23 AM
Plasma Plasma is offline
Freshman
 
Join Date: Apr 2002
Posts: 36
Default

Make something happen when the timer event is called / breakpoint.
Reply With Quote
  #6  
Old 01-17-2006, 10:54 PM
RandomPerson333 RandomPerson333 is offline
Newcomer
 
Join Date: Dec 2005
Posts: 3
Default

Well, it's not supposed to do anything if NumClients is 0...not much point sending a message if no one is there. But, yeah, obviously it would be a problem if that value was 0 when it shouldn't be. Besides, I think I fixed this problem by changing something totally unrelated, though now it's doing more odd things like sometimes forgetting to ping, causing the client to disconnect. I'd use TCP if it didn't keep crashing...
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
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock] "Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
 
"Pinging" Problems [VB6, Winsock]
"Pinging" Problems [VB6, Winsock]
 
-->