How can you change Network settings (IP Address, DNS, WINS, Host Name) with code in C#

Just made this in a few minutes: using System; using System.Management; namespace WindowsFormsApplication_CS { class NetworkManagement { public void setIP(string ip_address, string subnet_mask) { ManagementClass objMC = new ManagementClass(“Win32_NetworkAdapterConfiguration”); ManagementObjectCollection objMOC = objMC.GetInstances(); foreach (ManagementObject objMO in objMOC) { if ((bool)objMO[“IPEnabled”]) { ManagementBaseObject setIP; ManagementBaseObject newIP = objMO.GetMethodParameters(“EnableStatic”); newIP[“IPAddress”] = new string[] { ip_address }; … Read more

Volley – POST/GET parameters

For the GET parameters there are two alternatives: First: As suggested in a comment bellow the question you can just use String and replace the parameters placeholders with their values like: String uri = String.format(“http://somesite.com/some_endpoint.php?param1=%1$s&param2=%2$s”, num1, num2); StringRequest myReq = new StringRequest(Method.GET, uri, createMyReqSuccessListener(), createMyReqErrorListener()); queue.add(myReq); where num1 and num2 are String variables that contain … Read more

Get public/external IP address?

Using C#, With webclient its a short one. public static void Main(string[] args) { string externalIpString = new WebClient().DownloadString(“http://icanhazip.com”).Replace(“\\r\\n”, “”).Replace(“\\n”, “”).Trim(); var externalIp = IPAddress.Parse(externalIpString); Console.WriteLine(externalIp.ToString()); } Command Line (works on both Linux and Windows) wget -qO- http://bot.whatismyipaddress.com OR curl http://ipinfo.io/ip

Programming P2P application

P2P connectivity in a nutshell. Assume we’re talking about UDP here. The steps below can also be applied to TCP with some adjustments. Enumerate all your local IP addresses (usually only 1). Create a UDP socket on a given port number** for each adapter with an IP address. For each socket created in step 1, … Read more

How can I upload a photo to a server with the iPhone?

Header: @interface EPUploader : NSObject { NSURL *serverURL; NSString *filePath; id delegate; SEL doneSelector; SEL errorSelector; BOOL uploadDidSucceed; } – (id)initWithURL: (NSURL *)serverURL filePath: (NSString *)filePath delegate: (id)delegate doneSelector: (SEL)doneSelector errorSelector: (SEL)errorSelector; – (NSString *)filePath; @end Main: #import “EPUploader.h” #import <zlib.h> static NSString * const BOUNDRY = @”0xKhTmLbOuNdArY”; static NSString * const FORM_FLE_INPUT = @”uploaded”; … Read more