473,748 Members | 2,471 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
Nov 22 '05 #1
0 862

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

Similar topics

2
3893
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
1447
by: Gonçalo Rodrigues | last post by:
Hi, I have a problem with threads and sockets. I'll try to describe the problem in words with pseudo-code. I've been working on a few classes to make it easier to work with threads. This framework, let us call it that, consists in two parts. The first part is just a basic thread class deriving from threading.Thread with a few extra functionality that makes it easier for a thread to spawn a new thread and "father it". Each of its
0
1919
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 putting them in separate threads but no success there either) The issue has been raised in various...
0
3490
by: Gavin Williams | last post by:
I am working on a multi-threaded server for a Windows 2000 system and since "fork" doesn't work that great in a Win32 environment, I am trying to use use the "threads" module instead. When a thread is complete, the handle and thread are removed but the memory used when the thread was initially created does not appear to be released. Any new threads created afterward will grab new memory on top of where the previous left off. This is a...
0
969
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 thread count by 1. After the software running for around 1 hour windows cracks it as I am using too...
2
4567
by: jgbid | last post by:
Hi, I'm trying to build an IP Scanner inc c# for a specific port (80) and for specific IP Ranges. For example 24.36.148.1 to 24.36.148.255 My first step was to use TcpClient, but there are nothing to control Timeout Connection... and I wasn't interested to wait 25-30sec for each ip. After some search, it's look like Socket was the solution with
2
1639
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 he/she would implement it. Basically the application is a small GUI wherein the user can enter an
1
1172
by: Philip Zigoris | last post by:
Hi all, I have written a socket based service in python and under fairly heavy traffic it performs really well. But i have encountered the following problem: when the system runs out of file descriptors, it seems to stop switching control between threads. Here is some more detail: The system has n+2 threads, where n is usually around 10. This was
3
2353
by: Simon Dean | last post by:
Hi, I believe I have a website (I didn't do the original coding) which uses JavaScript/ASP to generate cookies. It's a shopping cart application called UCart I believe. The technologies involved are: ASP
167
8320
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++ doesn't have such functionality, say in its STL. This absence of a thread/object relationship in...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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

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.