473,569 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with increasing threads when communicating with UDP Socket

I have written an application using VB.Net 2003 which contains a single timer
control (Interval set to 5 seconds) and a function which uses the
BeginReceiveFro m Socket function.

The problem I am having is that everytime the timer runs and calls the
function which sends and receives data through the UDP protocol, it increases
the systems thread count by 1.

After the software running for around 1 hour windows cracks it as I am using
too many threads.

Does anybody know why this is happening and hope I can stop it??

CODE:

Public Sub UDPTest()

' Create endpoint
remoteIpEndPoin t = New System.Net.IPEn dPoint(System.N et.IÂ*
PAddress.Parse( '192.168.10.200 '), Â* 100)

' Create a UDP scoket for sending data
udpSocket = New Socket(AddressF amily.InterNetw ork,Â* SocketType.Dgra m,
ProtocolType.Ud p)

' Connect UDP Socket to device
udpSocket.Conne ct(remoteIpEnÂ* dPoint)

' Check if writeable then send data request to device
If udpSocket.Poll(-1, SelectMode.Sele ctWrite) Then
udpSocket.Send( sendBytes, sendBytes.Lengt h, SocketFlags.Non e)
End If

udpSocket.Begin ReceiveFrom(bÂ* ytes, 0, bytes.Length, SocketFlags.Non e,
remoteIpEndPoin t, New AsyncCallback(A ddressOf OnReceive), Nothing)

Console.Write(E ncoding.ASCIIÂ* .GetString(byte s))

End Sub

Public Sub OnReceive(ByVal ar As IAsyncResult)
On Error GoTo ErrorHandle
Dim iBytes As Integer = udpSocket.EndRe ceiveFrom(ar, remoteIpEndPoin t)
ErrorHandle:
End Sub
Jul 21 '05 #1
0 959

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3883
by: Tero Saarni | last post by:
Hi, I have several threads communicating with each other using events stored in Queues. Threads block on Queue.get() until somebody publishes an event in thread's event queue. I need to add support for sockets to the system. Thread needs to unblock when: - there is socket ready to be read, or
0
1908
by: Rod Stephenson | last post by:
I am developing an engineering application for modelling multiphase flows in large pipe networks, and have just discovered the joy of pyopengl for 3D visualization. However the incantation I'm using - with glut on Windows - doesnt coexist well with other python gui's - glutMainLoop() appears not to work alongside tkinter.mainloop(). (I tried...
0
854
by: David Dolheguy | last post by:
I have written an application using VB.Net 2003 which contains a single timer control (Interval set to 5 seconds) and a function which uses the BeginReceiveFrom Socket function. The problem I am having is that everytime the timer runs and calls the function which sends and receives data through the UDP protocol, it increases the systems...
2
1632
by: mastermagrath | last post by:
Hi all, I recently finished a small project using perl and tk/tcl which caused me several headaches. I have now decided to have a go at VB .net and thought a good place to start would be recreating the perl application. However, once again i'm running into similar headaches and wondered if i could get a real developers opinion on how...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.