|
You haven't said why you don't want to use the overloaded constructor to instanciate the client and specify the port.
The problem is that in order to listen for incoming data, you use the UdpClient.Receive method.
This method blocks until data is received, and with UDP being a connectionless protocol, you can never guarantee when data will be recieved so your left with having to listen for any/all incoming data over a specific port.
One way to achieve this is to run a UdpClient that listens for incoming data on a seperate thread which frees up the main thread to do it's normal work.
A seperate UdpClient can then be instanciated in the main thread whenever you need to send data.
I created a test project some time ago which you can download from here:
http://www.box.net/public/frq1a08ozh
It requires v2.0 of the .Net Framework but the source code should help point you in the right direction even if you using v1.1
Hope this helps
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
I made a Web User Control and it almost works how I want. I have a code behind setup on a web page. On the aspx page I have the custom control added and I can use the code from that page (ex. using my methods to setup the control). When I goto the code behind I don't know how to reference it so I can use its methods.
Thanks for the help.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
When you add your user control, you set it an id in the aspx, as in id="myControl". In the code behind, you can do myControl.XXXX to call methods on the control.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am actually making most of the code by hand, not using VS2005 to do the auto coding...
If I use VS2005 to auto code then it allows me to do it how you say. How do I do it by hand?
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
All VS does is put a member variable with that name and type in your code behind. If you do that, the framework will attach it to the control in the aspx and you can do just what I said from there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
I definition of .NET FRAMEWORK - all class object ( except int, char and ext. ) are sending to function as reference.
So in witch case i need to use ref/out in declaration of function ?
Thanks for any help.
|
|
|
|
|
Yes class objects are sent by reference.
using the 'ref' keyword would just result in the exact same thing - namely sending the object by reference.
using the 'out' keyword on the other hand is for forcing the parameter into being set within the method. So if you made a virtual class or an interface with a member class referencing a parameter with the 'out' keyword, it would force any class inhereting your class / interface to set a value to the parameter. Failing to do so would result in a compilation error.
Hope that makes it a bit clearer.
-Larantz-
|
|
|
|
|
Larantz wrote: using the 'ref' keyword would just result in the exact same thing - namely sending the object by reference.
No, it doesn't result in the same thing. It results in the reference being send by reference. What is sent is a reference to the reference to the object.
---
single minded; short sighted; long gone;
|
|
|
|
|
All parameters are sent by value, unless you specify ref or out . For a reference type that means that the value of the reference is sent.
You would use ref or out if you need to change the actual reference of the object, not just the contents of the object.
You rarely ever need to use ref or out . It's used sometimes for performance reasons.
---
single minded; short sighted; long gone;
|
|
|
|
|
value types ( that is, int/double/etc ) are not passed by reference unless you use ref. out and ref do exactly the same thing in MSIL, the difference is, the compiler won't allow any execution paths where an out variable is not given a value.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
i am working in a parent child form environment.
i have a function in the Parent Form
publib void call_funct()
{
panel2.Visible=true;
}
now when i access this function from Child form, the code within the function is accessed(i've checked it through applying breakpoints), but there is no effect of the code.
what i mean is that panel2 doesn't become visible.
how do i correct this??
thanks for the time
Saira
|
|
|
|
|
If you have instanciated your panel2 within the parent form like:
MyChildFormClass panel2 = new MyChildFormClass();
then you'll make it show by calling the Show() method:
public void ShowChildForm()
{
panel2.Show();
}
but if it's a normal usercontrol like System.Windows.Forms.Panel then you'll
make it show by:
public void ShowPanel()
{
this.SuspendLayout();
panel2.Size = new Size(sizeX, sizeY);
panel2.Location = new Point(ptX, ptY);
this.Controls.Add(panel2);
this.ResumeLayout();
}
-Larantz-
|
|
|
|
|
ur code isn't woking for me.
anyway
thanks for ur time
Regards
Saira
|
|
|
|
|
publib ???
Is panel2 sitting inside another control that is not visible ? Is it within the visible area of the form ? How was it created ? Is it part of the forms controls collection ?
Saira Tanwir wrote: accessing control of one form from another form
You should never do this. If you want to change the behaviour of a control on another form, you should expose a property that sets what you want, such as
public PanelVisible
{
get { return panel2.Visible;}
set { panel2.Visible = value; }
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How to move an icon that is on the desktop at some position.
C#
|
|
|
|
|
Hi,
the easy way is using Windows desktop, i.e. interactively.
Programmatically it is a rather complex job.
It involves:
- finding the right window (the desktop icons are all inside a listview which you could access
on WinXP by finding first "Progman" then "SHELLDLL_DefView" then "SysListView32").
- finding the right icon (if you know it by name, you could enumerate them all to find its
index in the list.
- sending it an LVM_SETITEMPOSITION message using SendMessage
All of the above require calling win32 functions from user32.dll with PInvoke.
You'll have to do a lot of searching both on CodeProject and on MSDN and/or Google.
|
|
|
|
|
Hi,
I'm new in c#,
Ihava dummy question about how to termite button events.
Sample
If Usernam.text<>'' then
press "button" let me to next field
if username.text='' then
press button diable for nex field
tnx
Dani
|
|
|
|
|
You should make the buttonNext disabled as default.
Then in your textbox' "content changed" event method you could do something according to the following:
private void textboxUsername_ContentChanged(object sender, EventArgs e)
{
if(textboxUsername.Text.Equals(validUsername))
buttonNext.Enabled = true;
}
Hope it's of some help to you.
-Larantz-
|
|
|
|
|
Hy...
Can anybody tell me if it's possible to rotate a TextBox.
And if is possible if I catch right-bottom corner and resize it to negative part.
10x
|
|
|
|
|
Nope. You'd have to write you own implementation that supports this, complete with all the drawing code. Or, find a 3rd party library that supplies a textbox that does this. I don't know of one myself.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want set password for folder in C#.net how?
and How do I know the contents of the file DLL and EXE?
I want to answer as soon as !!!!!!!!!!!!!1
yasofy
|
|
|
|
|
AL-yasofy wrote: I want set password for folder in C#.net how?
You can't. NTFS doesn't support individual passwords for folders.
AL-yasofy wrote: How do I know the contents of the file DLL and EXE?
Read it's documentation or open it using a utility like Depends.
AL-yasofy wrote: I want to answer as soon as !!!!!!!!!!!!!1
Impatient little snot, aren't you? This is a forum environment. The people here answer questions for free when they can, not when you demand it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I ask how can change background folder
and how hiden folder
and
share folder
all this in C#.net
yasofy
|
|
|
|
|
AL-yasofy wrote: ask how can change background folder
"Background folder"?? What does that mean?
AL-yasofy wrote: how hiden folder
Use the File.GetAttributes[^] method to get the directory attributes, than you modify them and write them back with the SetAttributes method.
AL-yasofy wrote: share folder
You'll have to use WMI classes and methods to create a new share using the Win32_Share[^] class. The .NET Framework doesn't have any support for creating and managing shares directly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi I have made an small application in C# from the book Network Programming with C# and VB.Net for capturing packets. Now my question is that author has shown application for a single machine but what if I want to do the same for a LAN where in from the server side i can get the traffic of clients is it possible in .Net using Raw Socket Capturing or Will I have to use WinPcap ? I would be happy to see your reply thanks.
|
|
|
|