winsock error with timer
winsock error with timer
winsock error with timer
winsock error with timer
winsock error with timer
winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer
winsock error with timer winsock error with timer
winsock error with timer
Go Back  Xtreme Visual Basic Talk > > > winsock error with timer


Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2001, 03:08 PM
david369
Guest
 
Posts: n/a
Default winsock error with timer


I am using winsock to 'ping' to another user, by using a timer to send a message every few seconds. I am having a problem when more than one user tries to connect to the host at the same port. Sometimes it works, but sometimes (i imagine if they try to connect at the same time) an error occurs when it can not connect.

If this happens i use a command to make it wait a random delay before attempting to reconnect. The problem is though, the timer seems to stop working. I have checked the interval remains the same, and it is still enabled, yet it will not run.

The only way it seems to connect is if i close the form and reopen it again. Is their a way to "reset" the object without closing the form (which loses all other data too). I have tried winsock1.close on the error but still no luck.

This is the code i have on the timer:

Winsock2.RemotePort = 1009
Winsock2.RemoteHost = "127.0.0.1"
Winsock2.Connect

Do Until Winsock2.State = sckConnected
DoEvents: DoEvents: DoEvents: DoEvents
Loop

Winsock2.SendData Text1


Any ideas of a solution to this?
If not could you please tell me a command to close the form and reopen it (not form.visible=false)

Thanks in advance.

Also.. is their a range of ports not commonly used by anything that i should use?

Reply With Quote
  #2  
Old 09-12-2001, 03:27 PM
Squirm's Avatar
Squirmwinsock error with timer Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default Re: winsock error with timer

Im confused as to whether your problem is with the timer or the winsock control, you seem to specify both. Anyway to reset the winsock:

<pre>If Winsock1.State &lt;&gt; sckClosed Then Winsock1.Close
Doevents</pre>

I wouldnt suggest looping until State = sckConnected. A better idea is:

<pre>Do Until Winsock1.State &lt;&gt; sckConnecting
DoEvents
Loop</pre>

Then is there is an error the loop will still end, otherwise it would never end in an error. As for the timer problem, I'm not sure...

__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
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 error with timer
winsock error with timer
winsock error with timer winsock error with timer
winsock error with timer
winsock error with timer
winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer winsock error with timer
winsock error with timer
winsock error with timer
 
winsock error with timer
winsock error with timer
 
-->