|
My chat application uses UdpClient class. It is working fine on LAN as well as over the internet. I can not recieve messages in one senerio, when I send message over the internet and the receiving party is indirectly connected to the internet like using a shared internet connection over LAN. How do I reach those clients?
There is no server program and both parties are connected directly through IPs.
Regards
|
|
|
|
|
Your probably talking about the common situation where each machine is sitting behind a router/NAT/Firewall. In this case, your application doesn't do anything different. Each user must change the configuration of their NAT/Firewall to forward the port that your chat program is using to the machine's local IP address, usually on the 192.168.x.x network.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the reply. Ok you got it right.. my client has a local IP address 192.168.x.x. How do I change the configuration of NAT to forward the port??
Regards
|
|
|
|
|
That's up to each individual router. You really can't do that in your code without writing a version for each manufacturer and different models of routers.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
One thing more... Udp being connectionless, the client at the other end is just sending messages to the public IP. How does it know that the message has to be forwarded to the 192.168.0.34 ?? There has be to some information at the sending end that the message is for 192.168.0.34 (local) on 205.166.6.33 (public IP)
I am so confused
|
|
|
|
|
Your actually sending to a specific port at an IP address, not just to the IP address alone. The router has a table that tells it where to forward individual ports to local IP addresses.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave. The problem is now solved.. I configured the NAT settings..
|
|
|
|
|
I made a class, derived from Panel...
Then i tried to insert my OwnPanel on the form in other project : I Made next steps:
I added references, inserted in toolbox new tab, in new tab inserted my dll, where my components placed.
Then, when i try to insert my OwnPanel on form i see next error message:"An exception occured while tryeing to create an instance of OwnPanel. The exception was "Exception of type System.StackOverflowException was thrown." ".
I can't understand...
Please help...
|
|
|
|
|
It would appear that you have code executing in your control's New or Initialize methods, or somewhere else for that matter, that calls itself recursively until the Stack is exhausted. You'll have to set a breakpoint in your code's New method and step through it line-by-line to see where the problem is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can we run a .NET web service on Apache server on Windows.
The .NET service is in J# and so Mono XSP seems not supporting this.
Help me if anyone know something regarding this.
Thanks in advance.
-ashish
|
|
|
|
|
I have a windows form with several richtextboxes. I have created a button which fires the fontDialogue to change the style of the selected font.
When I select the text to be changed and then click the button to change the font style the richtextbox control loses focus. However the style still gets applied to the tex that was selected.
The problem I have is when changing the font style of text within another richtextbox the previously selected text from the first richtextbox changes also.
How can test to see which control has text selected?
Here is the button event trigger:
private void btnFontStyle_Click(object sender, System.EventArgs e)
{
if(this.fontDialog1.ShowDialog() == DialogResult.OK)
{
foreach(Control ctrl in this.pnlMain.Controls)
{
if(ctrl.GetType() == typeof(System.Windows.Forms.RichTextBox))
{
if (((System.Windows.Forms.RichTextBox)ctrl).Modified)
((System.Windows.Forms.RichTextBox)ctrl).SelectionFont = this.fontDialog1.Font;
}
}
}
}
|
|
|
|
|
It would appear that you have a design flaw in your application. Both RichTextBox's will maintain their own Selection's whether they have the focus or not. Since your code is interating through all the controls on the form and changing the RTB's that have been modified, your code is applying the new font to all the RTB's that have been modified, not the one that last had the focus!
If you insist on having multiple RTB's on the form that the user can edit and change the font on, you'll have to implement a flag on your form that holds a reference to the last RTB to have the focus. Handle the GotFocus event of all your RTB's and set this flag pointing to the one that got the focus. Then, in your button click event, you'll know which RTB had the focus last without having to iterate through all the controls on the form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the input. I was going to do that but thought it would be unecessary to have code for each control. Thought there might be a generic method I could use.
I appreciate your help
|
|
|
|
|
It is. You can have one handler function that handles the same event for mutiple controls. If you look in the "Windows Form Designer generated code" section, you'll see that things like the button click event get wired up with a statement like:
this.button1.Click += new System.EventHandler(this.button1_Click);
Well, if you have multiple buttons, you can point them all at one click handler if you need to handle all their clicks in the same code:
this.button1.Click += new System.EventHandler(this.button1_Click);
this.button2.Click += new System.EventHandler(this.button1_Click);
this.button3.Click += new System.EventHandler(this.button1_Click);
Notice, each one of these is an addition statement.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You have some, or you want some ? What port in particular ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
I'm writing a terminal application and I want to open a file through FileOpenDialog. This class need using System.Windows.Forms;
I can't do it under terminal applicaton.
How can I do that? Do I need change some project options? Please tell me the details. I/m a new c# programmer
Thnak you
|
|
|
|
|
Just add a reference to System.Windows.Forms.dll to the project and you should be fine. (Right click on Project in Solution Explorer, click Add References, select System.Windows.Forms.dll in the listbox that comes up).
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you for your help. It works.
I have another question. In windows application I can write System.Console.WriteLine( "something" )
The program complies with no problems but the console never showup. Is there any solution?
Thank you
|
|
|
|
|
Are you sure you want a console to appear? Maybe you can make do with writing to the Trace?
In any case, the reverse of what you did the first time will solve your problem. Create a console application and copy/paste the form code in Main.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Here's the setup...I have 3 overlapping UserControls and I'd like for all but the last one to be fully transparent. My problem, however, is when I set the appropriate styles, etc., the transparency effect goes all the way through the controls and all I can see if the underlying Form. This obviously isn't what I want.
Think 3 Frames... event_frame, drag_frame, render_frame. The event_frame handles the simple mouse events, the drag_frame displays and dragging/drawing upon mouse movement, and the render_frame displays all the finialized objects.
So basically I'd like for the event & drag frame to be transparent, but for the effect to stop at the render_frame. Obviously I'm fairly new to C#, so if I've missed something basic I apologize.
And one other quick question...I was wondering if there was an effective way of Clearing a graphics object? And not like the current .Clear(Color.*) method. Is there some way in which to just dump the contents of the graphics object? This one has me stumped as well.
Yet any help or suggestions on where to find a good solution would be greatly appreciated, thanks!
|
|
|
|
|
And to add a note to my second question there...I've tried using the alpha bit set to 0
*.Clear(Color.FromArgb(0,Color.White));
and that simply produces and entirely black UserControl. Just thought I'd mention that as a way I've tried to 'transparently' .Clear() a graphics object...to no avail.
|
|
|
|
|
how can i do it for a toolwindow?
|
|
|
|
|
Can't you just set those properties on the form in the designer ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In Properties set control box to false.
|
|
|
|