|
thanx,i thought that long .parse() can convert ip with dots to long, if i need to do this i have to remove the dots and format the string isn't it, but again the problem is will IPEndPoint take it as an valid ip, my code is
IPEndPoint ipendpt = new IPEndPoint(long.Parse(xml.readViewdetails(SystemVariables.VIEWDEATAILS_IP)), 7576);
this method reads a xml file and return the ip as string , is there a better way i can do this?
|
|
|
|
|
Yes, you will need to remove dots. As for IPEndPoint it should take it as a valid ip address. Anyway, why don't you try it?
|
|
|
|
|
|
i tried the way you suggested , but got an error saying the "The requested address is not valid in its context"
the ip that i gave is "192.168.1.84" and made the string 192168184 by removing ".", now the ip taken is "248.64.116.11", could you tell me the problem here. is it a problem of byte order , if so how can i solve this ?
|
|
|
|
|
You have to use the other overload (IpAddress,Int32 ) of IPEndPoint .
string ipAddress = xml.readViewdetails(SystemVariables.VIEWDEATAILS_IP);
IpAddress ip;
IPEndPoint ipendptp;
if(IpAddress.TryParse(ipAddress,ip))
{
ipendpt = new IPEndPoint(ip, 7576);
}
else
|
|
|
|
|
Why are you using string and long when have an IPAddress class?
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
could you give me some links to find more info about this, i tried with IPAddress but it takes byte[] or long(ipaddress), i converted the string to byte[] and gave it to IPAddress constructor, but at run time it says that the ip is ont in this context,(some other ip)
|
|
|
|
|
For christ's sake dude, ever heard of google?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
How can i access a folder from a listening ip address using socket.
How can i get the path? for eg: http://198.169.1.23/folder.image.jpg
Regards,
Yesuprakash
|
|
|
|
|
If you are using C#2.0 or later you can use inbuilt ftp functionality (if not there are libraries available). Google and MSDN will both give you what you are looking for with code samples.
Good luck!
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Your question makes no sense.
There's no association between a listening socket and a folder.
What are you trying to ask?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
I have a string array, but may have duplicate strings. Any built-in or smart way to remove the duplicate ones and generate a string array contains only unique ones?
For example, the input array is {"abc", "bcd", "abc"}, the unique output array is {"abc", "bcd"}.
thanks in advance,
George
|
|
|
|
|
from what I know there's no such thing and you'd have to iterate thru and pick the unique ones manually. it's not that difficult you know
|
|
|
|
|
Thanks Igor,
Good to know .Net does not provide such a class.
regards,
George
|
|
|
|
|
I dunno why a set class is not included, but it's easy to write one. Just have a list inside, and check if an entry exists before adding it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks Christian,
What do you mean "have a list inside"? I am talking about string array, I am not sure where is the list you are talking about. Show some pseudo code?
regards,
George
|
|
|
|
|
public class set<t>
{
private List<t> theList;
public bool Add(T item)
{
if (theList.Contains(item)) return false;
theList.Add(item);
return true;
}
}
This is the start of a set class, a container that only contains one of any object.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks Christian,
I like your idea. I am surprised why there is no built-in Set class in .Net.
regards,
George
|
|
|
|
|
May be Array.FindAll can help you. Check out MSDN for it.
Another way could be:
1. Create a list/hashtable. Then loop through the array.
2. Check if the element exists in the list/hashtable.
3. If it does its a duplicate value. Remove it from array.
4. If it doesnt add it to the list/hashtable.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
Hi d@nish,
I have studied related MSDN page about Array.FindAll, but I do not think it could help me in my solution. Do you have any pesudo code to show your idea of using Array.FindAll to make a unique string array?
regards,
George
|
|
|
|
|
You have to iteretae it.You can use some generic for that
Cheers!!
Brij
|
|
|
|
|
Hi Brij,
"some generic for that" -- do you have some more words on this? Or some pseudo code?
regards,
George
|
|
|
|
|
List<string> newArray = new List<string>();
foreach (string token in yourArray)
{
if (!newArray.Contains(token))
{
newArray.Add(token);
}
}
|
|
|
|
|
Thanks Igor,
I like your solution!
regards,
George
|
|
|
|
|
no worries
|
|
|
|