|
Hello,
has somebody a tutorial for UDP Hole Punching or STUN? I have a few problems with the UDP Punching and a few points which i don't understand, maybe somebody could help me:
Here an article to UDP Hole Punching: http://www.h-online.com/security/How-Skype-Co-get-round-firewalls--/features/82481[^]">
so, UDP Hole Punching works like this, you have 2 clients and one server which knows the IP-Adresses of the clients and their ports over which they would send their UDP Packages (so here's the first problem, from where does the server know, which ports the client use?)
first step: Client1 gets the IP-Adress and the Port (see above, here's the problem) of Client 2.
second step: CLient1 (IP: 1.1.1.1:1000) sends a package to Client 2 (IP: 2.2.2.2:???? Which port is it?) over UDP, which will be deleted on the NAT-Router of Client 2 (no incoming packages)
third step: Client 1 sends the server the information to initiiate a connection to Client 2 over the port 1000 (Client 1) and the Port ???? (Client 2).
fourth step: CLient 2 gets the information to create a udp-connection to CLient 1 (IP: 1.1.1.1:1000) over his Port ????.
Well, you see the principle is easy, but the Ports of CLient 2 are my big problem, how do i find that out? Has somebody experience in UDP Hole Punching or STUN? Well, what's STUN? I get from a STUN server only my Port, from which i sendet my package to the Server, but another client couldn't do anything with that port and thats the problem how to find out the port of my partner.
Many Thansk
|
|
|
|
|
Hi,
I am also trying to figure out the solution for the same problem.
Does anyone have the answer?
|
|
|
|
|
I guess, this is how it should be done
1. You get back your mapped port and mapped address from the STUN
2. CLient2 also gets back its mapped port and mapped address from the STUN
3. The STUN server should store these info. When either clients want to communicate with the other, it sends a request to the STUN server. The Stun server then sends a message to both the clients with the mapped Addr and port of their counterpart.
4. After this, hole punching can be done by the method shown in the article above.
|
|
|
|
|
Hi guys, i'm interesting at this. have you found some examples or howto?? How do you solve this problems??
|
|
|
|
|
Hi guys, i'm interesting at this. have you found some examples or howto?? How do you solve this problems??
PLEASE HELP ME
|
|
|
|
|
hi guys
if anybody found any solution regarding NAT traversal , please email me at : sanjudusad@gmail.com
Thanks in advance
|
|
|
|
|
hi everyone,
i want to know how can i minimize my program in the system try , in fact i want to know how can i create my program that when a user clicks on the minimize button program minimize in the system try (beside the system digital clock)?
I'm coding with C#.Net....tanx a lot
|
|
|
|
|
Add a NotifyIcon to your form. Subscribe to the form's Resize event, check it's state and if minimized, set Visible to false and the NotifyIcon's visibility to true. You'll need to add a context menu as well so your tray icon has funtionality but that's the basics.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
You can use NotifyIcon to show icon in the system tray. To hide your form, call Hide() method.
|
|
|
|
|
And one more thing..
You need to set show in taskbar set to false;
|
|
|
|
|
Hello,
I have a problem which shouldn't be one really. I need to convert a program to a dll but when I compile it with csc I get an empty dll (checked with DumpBin.exe).
I created a small test class and compiled a dll from it but I cannot invoke the method using Dllimport, it says it cannot find an entrypoint named testMethod.
The code:
test.cs:
using System;
namespace test
{
public class test
{
public string testMethod()
{
return "test";
}
}
}
dllTest.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace dllTester
{
public class dllTester
{
[DllImport(@"test.dll", EntryPoint = "testMethod")]
static extern string testMethod();
static void Main(string[] args)
{
Console.WriteLine(testMethod());
Console.ReadKey();
}
}
}
I compile test.cs: csc /t:library /out:test.dll test.cs without any errors or warnings.
I compile dllTester: csc /out:dllTester.exe dllTester.cs without any errors or warnings.
When I try to run dllTester I get this:
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'testMethod' in DLL 'test.dll'.<br />
at dllTest.dllTester.testMethod()<br />
at dllTest.dllTester.Main(String[] args)
Any ideas?
Br
Trih
|
|
|
|
|
Do you want to use a .NET Dll in a .NET Application, but using DllImport ??
|
|
|
|
|
As far as I know DllImport works with unmanaged assemblies, while your code produces a managed one.
|
|
|
|
|
First of all, I think the previous poster is correct - DllImport is definitely meant for unmanaged libraries, like the Windows APIs, and not managed (.net) ones like yours. I can't say for sure that it cannot be used with managed assemblies, but I doubt it - there are better ways to do this you see.
That having been said, your DLL does not have any entry points! Entry points are necessarily static, and your library only contains a class with an instance method.
If you wanted to "convert" the program to a DLL in order to make it available to non-.NET clients there is presumably a way, but I don't know what it is (Google is your friend though).
If you just want to use the assembly in other .net applications, the simplest is of course to just add a reference to it. But if you want to load assemblies dynamically (this can be useful for things like a plug-in architecture) you should have a look at the Assembly class and in particular the Load() method. There's lots of goodies here and you can easily do things like discover all classes that implement certain interfaces or derive from particular classes.
|
|
|
|
|
How can i stop an while loop by clicking a button?
eg:
A while loop is executing, i want to stop the while loop from outside like a button click
Thankyou
YPKI
|
|
|
|
|
you must put that loop in a new thread. then use a flag, like _isButtonClicked.
If yes, then break.
|
|
|
|
|
how to put a while loop in a thread?
|
|
|
|
|
The easiest way to put it in a background thread is to make sure you have a method signature that take one parameter of type object and then use ThreadPool.QueueUserWorkItem(new WaitCallback(method)) - "method" simply being the name of the method you wish to call.
bool stop;
void method(object dummy)
{
while (!stop)
{
...
}
}
However, be aware that the code in method should not use any references to any controls. By default, doing so will result in an exception. You can make this go away by setting Control.CheckForIllegalCrossThreadCalls to false , but it's not a good practice to do so, I think because the controls aren't designed to be thread-safe. Depending on what you're doing, you may or may not decide that you don't care and just use the controls from the background thread anyway. I've done it many times (in apps for my own use only, where I don't really care if this one day leads to some odd behavior of a button because two threads tried to update it's text property at once, resulting in something weird and maybe beautiful) and I haven't had any problems with it, but there is undoubtedly a good reason why Microsoft decided to disallow this by default.
|
|
|
|
|
I don't know do you want to break immediately, but something like this may help
bool stop = false;
while(!stop)
{
..dosomething
}
or
while(true)
{
if(stop)
break;
}
and on your button_click
{
stop = true;
}
hope it helps
|
|
|
|
|
A bit vague. Is your while loop executing in a background thread? If it's executing on your GUI thread and your not calling Application.DoEvents it won't ever break!
Regards,
Rob Philpott.
|
|
|
|
|
while loop is runnung normally, not in thread.
how can i stop using Application.DoEvents
|
|
|
|
|
Create a boolean member:
private bool _running = true;
In the button click event set it to false:
_running = false;
Make your while loop look like this
while (_running)
{
Application.DoEvents();
}
Regards,
Rob Philpott.
|
|
|
|
|
Problem with this is that there won't be any click events, because it won't check this.
You can better use a thread and in this thread you put your code.
Something like this (out of my head):
private bool _running = true;
public static void main(args[])
{
Thread t = new Thread(threadFunction);
t.Start();
}
public void threadFunction()
{
while(_running)
{
}
}
public void Button1_Clicked(object sender, EventArgs e)
{
_running = false;
}
Don't know if the 'thread' part is correct, the rest is ok
|
|
|
|
|
Actually, its perfectly valid. The Application.DoEvents keeps the message pump pumping and is the way mutitasking used to work in the Windows 3.x world.
Admittedly, I prefer your way of doing it but the gentleman suggested he didn't want to use background threads.
Regards,
Rob Philpott.
|
|
|
|
|
I've never used the Application.DoEvents() function. Didn't even know the existance of it.
With that in my mind, I totaly agree with you.
|
|
|
|