473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Public UDP socket accessed by multiple threads ???

I am attempting to create a UDP socket where inbound traffic is handled by one thread and outbound traffic is handled by another thread. The primary problem that I am having is accessing the thread from more than one thread. It also seems the .NET does not support public global socket delcarations. Anyone got any ideas?

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 15 '05 #1
3 1871
When you have the socket ref, you can pass it to any method or constructor
(say you have one class for reader and one for writer.) You will not find
(if you do, please let me know) explicit reference saying this is supported
in the winsock 2.0 or .net without syncronization. However, I have asked
this question before and got a reply from MS that one reader and one writer
would be ok. See the other post on this - maybe a 3 days ago.

--
William Stacey, MS MVP

"cSharpDotNet" <dotnet@-NOSPAM-enme.net> wrote in message
news:u3****************@TK2MSFTNGP12.phx.gbl...
I am attempting to create a UDP socket where inbound traffic is handled by one thread and outbound traffic is handled by another thread. The primary
problem that I am having is accessing the thread from more than one thread.
It also seems the .NET does not support public global socket delcarations.
Anyone got any ideas?
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 15 '05 #2
The problem is that a method used for threading does not allow for parameters to be passed to it. Is there a way around this? I would really like to be listening for UDP in one thread and sending UDP in another.

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
Nov 15 '05 #3
Create a new class. The class will contain the reader thread. You could
also create the writer thread in the class or create another class that
contains the writer thread. Then:
1) Create the socket and get the ref.
2) Create the reader (and writer) class instances, pass in the ref to the
socket during construction of the class.
3) Now the class (or classes) have the ref to the socket. Store that in a
private field of the class.
4) Make a Start() method on the class. This method will start the thread
and use a private method for the start delegate. This method will have
access to the private socket ref. Now you have access to the socket. Other
classes could get access the same way. Does that make sense? hth

--
William Stacey, MVP

"cSharpDotNet" <dotnet@-NOSPAM-enme.net> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...
The problem is that a method used for threading does not allow for parameters to be passed to it. Is there a way around this? I would really
like to be listening for UDP in one thread and sending UDP in another.
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest

Community Website: http://www.dotnetjunkies.com/newsgroups/

Nov 15 '05 #4

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

Similar topics

7
by: Gabriele Farina | last post by:
Hi, I'd like to manage multiple socket connection without having to use Threads. I'd like to manage every connection when it is returned from socket_Accept(), without having to wait for the...
5
by: Russell Warren | last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it a cross-process/system setting or does it stay local in the application in which it is called? I've been testing this and...
0
by: =?Utf-8?B?ZWNvdWxzb24=?= | last post by:
I would appreciate any help in solving this one. I am creating client multiple threads each one creates a client tcp socket to same server and port: m_remoteEP = new...
1
by: jecheney | last post by:
Hi, Im currently using the following code for reading/writing to a network socket. private StreamReader clientStreamReader; private StreamWriter clientStreamWriter; .... TcpClient tcpClient...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.