I use .net 3.5/c#
I need to get server's IP, I was using this code:
string strHostName = Dns.GetHostName();
IPHostEntry hostInfo = Dns.GetHostEntry(strHostName);
string serverIpParam = hostInfo.AddressList[0].ToString();
return serverIpParam;
However, after a switch to Windows 2008 server, my IP has letter format instead of usual format (digits). MSDN doesn't shed any light on this.
Any ideas what I should change to get the server IP?
Thanks
Did you looked at all the addresses that are returned by hostInfo.AddressList?
When I execute the following in LinqPad:
string strHostName = System.Net.Dns.GetHostName();
System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostEntry(strHostName);
for(int index=0; index < hostInfo.AddressList.Length; index++) {
Console.WriteLine(hostInfo.AddressList[index]);
}
IT will return me a whole list of network interfaces.
In your case, I think the first entry points to an IPV6 address
Related
I would like to retrieve the public IP address associated with a given network interface. I need to do something like
client = NetworkManagementClient(...)
interface = client.network_interfaces.get('rg', 'nic-name')
ip_config_id = interface[0].public_ip_address.id
ip_config = some_magic(ip_config_id) # What goes here?
return ip_config.ip_address
This question suggests that in order to implement the some_magic routine, I should parse the ID (by splitting on slashes) and call client.public_ip_addresses.get(). This question indicates that I can call resource_client.resources.get_by_uid, but that doesn't return a PublicIPAddress object (I know I can call as_dict on it and get the data that way).
Is there a way to get an object of the appropriate type (in this case PublicIPAddress) from an object's ID in Azure (without manually parsing the ID)?
Update:
Due to this issue: public_ip_address method within NetworkManagementClient will not return values, we cannot fetch the ip address from PublicIPAddress.
So currently, you can use any other workaround, For example:
myip = client.public_ip_addresses.get(" resource_group_name","public_ip_address_name")
print(myip.ip_address)
You can change this line of code ip_config_id = interface[0].public_ip_address.id to something like my_public_ip_address = interface.ip_configurations[0].public_ip_address, then the return type is PublicIPAddress.
For example:
I've been trying to figure this out for the past day or two with minimal results. Essentially what I want to do is send my selected comps in After Effects to Adobe Media Encoder via script, and using information about them (substrings of their comp name, width, etc - all of which I already have known and figured out), and specify the appropriate AME preset based on the conditions met. The current two methods that I've found won't work for what I'm trying to do:
https://www.youtube.com/watch?v=K8_KWS3Gs80
https://blogs.adobe.com/creativecloud/new-changed-after-effects-cc-2014/?segment=dva
Both of these options more or less rely on the output module/render queue, (with the first option allowing sending it to AME without specifying preset) which, at least to my knowledge, won't allow h.264 file-types anymore (unless you can somehow trick render queue with a created set of settings prior to pushing queue to AME?).
Another option that I've found involves using BridgeTalk to bypass the output module/render queue and go directly to AME...BUT, that primarily involves specifying a file (rather than the currently selected comps), and requires ONLY having a single comp (to be rendered) at the root level of the project: https://community.adobe.com/t5/after-effects/app-project-renderqueue-queueiname-true/td-p/10551189?page=1
Now as far as code goes, here's the relevant, non-working portion of code:
function render_comps(){
var mySelectedItems = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).selected)
mySelectedItems[mySelectedItems.length] = app.project.item(i);
}
for (var i = 0; i < mySelectedItems.length; i++){
var mySelection = mySelectedItems[i];
//~ front = app.getFrontend();
//~ front.addItemToBatch(mySelection);
//~ enc = eHost.createEncoderForFormat("H.264");
//~ flag = enc.loadPreset("HD 1080i 25");
//app.getFrontend().addItemToBatch(mySelection);
var bt = new BridgeTalk();
bt.appName = "ame";
bt.target = "ame";
//var message = "alert('Hello')";
//bt.body = message;
bt.body="app.getFrontend().addCompToBatch(mySelection)";
bt.send();
}
}
Which encapsulates a number of different attempts and things that I've tried.
I've spent about 4-5 hours trying to scour the internet and various resources but so far have come up short. Thanks in advance for the help!
Below is the code i am running with all other.. Its running perfectly adn its showing all the desired locations on map.
But what i want now is to store all the marked locations in such a way that i can show them as a list on a new page.
I am not able to retrieve the resulted location from map in the form of some string or may be something else which can be displayed as a list ...
private void Button_Click_3(object sender, RoutedEventArgs e)
{
MapsTask mapsTask = new MapsTask();
string search = "Coffee";
mapsTask.SearchTerm = search;
mapsTask.ZoomLevel = 2;
mapsTask.Show(); }
The MapsTask does not return any information.
If you're looking to get Points of Interest for a given location, you may have to use an external service such as the HERE Places API.
I'm using getnameinfo as follows:
ifaddrs *ifaddr = NULL, *ifa = NULL;
int rc, family, insize;
rc = getifaddrs(&ifaddr);
...
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
family = ifa->ifa_addr->sa_family
insize = (family == AF_INET) ?
(int)sizeof(struct sockaddr_in) :
(int)sizeof(struct sockaddr_in6);
char host[HOST_NAME_MAX];
rc = getnameinfo(ifa->ifa_addr, insize,
host, sizeof(host), NULL, 0, NI_NUMERICHOST);
}
...
When the function returns with an IPv6 address, it include the interface appended to the numeric IP address:
fe80::62a4:4cff:fe05:dc1b%eth0
What's the purpose of appending the interface to the numerical IP address?
Is there a flag available that controls the appending of the interface to the IP address?
fe80::* addresses are link-local in scope, which means the address is only valid for that particular network, the same address may reference a difference host on a different network. It is thus meaningless to specify a link-local address without specifying which network adapter. Also, DNS becomes rather meaningless outside of link-local scope such as provided by ZeroConf / multicast-DNS.
Unix hosts tend to specify the adapter by name, Windows hosts will specify the adapter by index. Note that Windows maintains separate interface indexes for IPv4 and IPv6.
I am making a page which pulls from the user's browser their preferred language, via the Request.UserLanguages....which returns a two letter code (ex. "en") or detailed code (ex. "en-GB") .
I basically get the string of user languages (they are in order of preference) and store them in a string array. Then I use a loop to check if the language code in the first position of the string array is any of the codes for a certain language (another string array hard coded in).
Is there a better way to do this? I'm noticing increased load time and am worried additional languages will further slow the page load...
if (!IsPostBack)
{ //Holds possible user languages preferences to check client machine against
String[] compJapaneseLang = { "ja-jp","ja","jp","jpn","euc","shift-jis" };
}
//Get client machines langugage preferences
String[] userLang = Request.UserLanguages;
//Loop through variation of preferences from possible user langugaes
for (int i = 0; i < compJapaneseLang.Length; i++)
{
//IF JAPANESE
if (userLang.GetValue(0).ToString().ToLowerInvariant().Equals(compJapaneseLang.GetValue(i).ToString().ToLowerInvariant()))
cc.JapeneseObject();
}
Thanks!
Storing them in a list turned out best, not really much else one can do....