I'm using AxInterop.MSTSCLib.dll in my app to remote to my server
the code is common like below:
var rdp = new AxMSTSCLib.AxMsRdpClient6NotSafeForScripting();
rdp.Server = "ServerAddress";
rdp.UserName = "Username";
sec.ClearTextPassword = "password";
rdp.Connect();
now i want to remote as UDP protocol
the server pc is ready for udp remote(udp components installed) and i tested it by Remote Desktop
but what i do in my app and code to remote to server as UDP enabled?
depending on this answer , you need to use this code to enable the remote desktop if i understand you well this code what you need
try
{
RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, TargetMachine.Name);
key = key.OpenSubKey(#"SYSTEM\CurrentControlSet\Control\Terminal Server", true);
object val = key.GetValue("fDenyTSConnections");
bool state = (int)val != 0;
if (state)
{
key.SetValue("fDenyTSConnections", 0, RegistryValueKind.DWord);
MessageBox.Show("Remote Desktop is now ENABLED");
}
else
{
key.SetValue("fDenyTSConnections", 1, RegistryValueKind.DWord);
MessageBox.Show("Remote Desktop is now DISABLED");
}
key.Flush();
if (key != null)
key.Close();
}
catch
{
MessageBox.Show("Error toggling Remote Desktop permissions");
}
Related
I have Http server running on my PC, I can use localhost or 192.168.1.69 talk to the server.
I have a tablet in the same wifi as the PC, when I do 192.168.1.69:8080/hello
I don't get any response.
I tried set up port forwarding on router, added .exe to firewall trust, also tried use public ip(that open router login page) with port number. but they doesn't help,
public HttpServer(int port)
{
if (!HttpListener.IsSupported)
{
// Requires at least a Windows XP with Service Pack 2
throw new NotSupportedException(
"The Http Server cannot run on this operating system.");
} // end if HttpListener is not supported
_httpListener = new HttpListener();
_httpListener.Prefixes.Add("http://localhost:" + port + "/");
_httpListener.Prefixes.Add("http://192.168.1.69:" + port + "/");
_resourceLocator = new Locator();
}
public void Start()
{
if (!_httpListener.IsListening)
{
_httpListener.Start();
_running = true;
_connectionThread = new Thread(new ThreadStart(this.ConnectionThreadStart));
_connectionThread.Start();
}
}
I have to check remote IP and Port is available or not.If its is available it will move to next form.If not available it should come to the initial state.I tried using this
while (true)
{
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
-------
-------
-------
}
I am showing the example coding.it was checking local IP and port and moving to next form.it will check local port and IP is available.if port and IP not available it will come to the initial stage and it was working fine.same thing i have to check in remote Port and IP.
Use the Ping class of .NET to find out if the system is up and connected, the use the PortScanner to check if the port is open. check these links for further reading and exploring.
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx
http://social.msdn.microsoft.com/Forums/vstudio/en-US/8e4410bd-307f-4264-9575-cd9882653945/help-with-portscanner-in-c?forum=csharpgeneral
OR
public static bool PingHost(string hostUri, int portNumber)
{
try
{
using (var client = new TcpClient(hostUri, portNumber))
return true;
}
catch (SocketException ex)
{
MessageBox.Show("Error pinging host:'" + hostUri + ":" + portNumber.ToString() + "'");
return false;
}
}
I am using DotRas library, creating RasDevice, Rasentry , adding Rasentry to RasPhoneBook and finally calling RasDialer.Dial().
RasDevice device = RasDevice.GetDevices().Where(o => o.Name == "(PPPOE)" && o.DeviceType == RasDeviceType.PPPoE).FirstOrDefault();
if (device != null)
{
MessageBox.Show("Found " + device.Name.ToString() + device.DeviceType.ToString(), "hah!", MessageBoxButtons.OK);
}
else
{
MessageBox.Show("Device not found", "Error", MessageBoxButtons.OK);
}
RasEntry entry = RasEntry.CreateDialUpEntry("Dialupnamexyz", "+880000000", device);
this.rasPhoneBook1.Entries.Add(entry);
this.rasDialer1.EntryName = EntryNameSet;
this.rasDialer1.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers); ;
this.rasDialer1.Credentials = new System.Net.NetworkCredential(userName, userPassword);
this.rasDialer1.DialAsync();
Connection is established. However, when i tried using internet explorer its down.
I tried manually dialing up the programmatically created entry, it say connection established. But again in internet explorer its down.
I am using windows 10. Is there anything i am missing here?
Thanks for help.
I have to check remote IP and Port is available or not.If its is available it will move to next form.If not available it should come to the initial state.I tried using this
while (true)
{
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
-------
-------
-------
}
I am showing the example coding.it was checking local IP and port and moving to next form.it will check local port and IP is available.if port and IP not available it will come to the initial stage and it was working fine.same thing i have to check in remote Port and IP.
Use the Ping class of .NET to find out if the system is up and connected, the use the PortScanner to check if the port is open. check these links for further reading and exploring.
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx
http://social.msdn.microsoft.com/Forums/vstudio/en-US/8e4410bd-307f-4264-9575-cd9882653945/help-with-portscanner-in-c?forum=csharpgeneral
OR
public static bool PingHost(string hostUri, int portNumber)
{
try
{
using (var client = new TcpClient(hostUri, portNumber))
return true;
}
catch (SocketException ex)
{
MessageBox.Show("Error pinging host:'" + hostUri + ":" + portNumber.ToString() + "'");
return false;
}
}
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Listening to Port 5060
I am developing a SIP client.And I have a question.
I want listen 5060 port for catch the SIP Server Message.For this,I coding something.(Also I take admin rights in program)
But I get SocketException: "An attempt was made to access a socket in a way forbidden by its access permissions" (Native error code: 10013)...
My Code:
private void ListenPort() {
WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);
TcpListener server = null;
Int32 port = 5060;
IPAddress localAddr = IPAddress.Parse("192.168.1.33");
server = new TcpListener(localAddr, port);
Byte[] bytes = new Byte[1000];
String data = null;
while (hasAdministrativeRight == true)
{
server.Start();
int i = 0;
while (1==1)
{
TcpClient client = server.AcceptTcpClient();
NetworkStream stream = client.GetStream();
data = null;
i = stream.Read(bytes, 0, bytes.Length);
data += System.Text.Encoding.ASCII.GetString(bytes, 0, i);
label3.Text += data;
this.Refresh();
Thread.Sleep(500);
}
}
}
Where do you think the problem?
Have you checked that no other program is already using port 5060? That's what this error can mean.
See this discussion on the matter: http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/d23d471c-002a-4958-829e-eb221c8a4b76/
You need to call server.Start() outside the while loop and before the first AcceptTcpClient call.
Also try using IPAddress.Any instead of IPAddress.Parse("192.168.1.33") for your listener ip
Make sure any other SIP Server program not installed as a Windows service which has using according port.
Type in netstat -an and it will show you the “listening” ports or try to googling port check softwares.
And check your SIP Server configuration for is it running over TCP or UDP.