Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
what do we mean by dynamic IP ?
and how we can implement a simple example on it using sockets in vb.net ?
thanks all
Read a book about the IP prtocol and the WIndows doucmentation.
Dynamic IP refers to an IP address that is dynamically assigned to a computer when the computer connects to the physical network ,by means of a DHCP server which dynamically configures the host (with a dynamic IP). The opposite is a STATIC IP which is hard-coded into the computer configuration (i.e. you set it statically).
More is in the documentation. This is a low level beginner question - answering it without a lot of context is hard. Books and Documentation provide the context.
A dynamic IP address is assigned from a DHCP server (Dynamic Host Configuration Protocol).
When your network adapter connects to the network, it asks the DHCP server for a lease on an IP address. The DHCP server returns an IP address which has a limited life time. When the lease expires, the network adapter has to ask for a new lease.
The lifetime of a lease is usually something like two hours or 24 hours, whatever is appropriate for the network. A short lifetime for the lease doesn't mean that you change IP address often, because most of the time you will get a lease for the same IP address that you had before.
For a static IP address the DHCP server isn't involved, you simply enter the IP adress in the network settings.
You can't implement dynamic IP addresses using sockets, because you need to have an IP address already to establish a socket connection.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
How can I get the client's IP Address? When I use HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] I get something like [::1]:12473
When I use HttpContext.Current.Request.UserHostAddress I keep getting ::1
When you run your code local, you get a ::1 (localhost).
If you publish to Azure, you should get the correct IP address.
You can expand your code by checking for the HTTP_X_FORWARDED_FOR header as well. This returns the correct client IP address when proxies and/or load balancers are involved.
string ipAddress = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ipAddress))
{
ipAddress = HttpContext.Request.ServerVariables["REMOTE_ADDR"];
}
This question already has answers here:
Listening for an Ethernet Cable Unplugging Event for a TCP Server Application
(4 answers)
Closed 5 years ago.
I have an application with one server and one client.
How the client will know if the server cable is unplugged or disconnect? Is there event for that?
I don’t want to set a timer to check occasionally if the server gets messages…
And i don't want to use poll...
Thanks,
Elad
Refer at that questions :
Stack overflow 1
StackOverflow 2
Yopu have to analyze the connection status in all the phases and understand in wich phase are the problem, anyway why the connection doesn't works.
There are also other link that refer to your question :
Stack overflow 3
Blog
Last method, work with NetworkChange.NetworkAvailabilityChanged Event
Link : enter link description here
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a problem where users have moved files and data to a NAS. This causes a number of problems. I would like to detect if the network disc users have moved files and data to is a NAS. I want to do this programmatically from a C# program. I want to alert them that this move could cause problems. Is this possible? I've found no way to tell if a network drive is NAS or not from C#/.Net but I haven't found anyone saying it cant be done either.
Is there any way to tell if a network drive is a NAS programmatically?
I have revised my question.
However, I've had a discussion with the people giving me this issue and I don't belive that the fact that a network disc is a NAS is the problem. Thanks to your comments here I asked a few questions and it turned out that we were talking about different things. The problem would probably be the same no matter what type of network storage that would be used.
But just out of curiosity, would it be possible to tell if a network disc is a NAS programmatically?
You need to tie these three things together:
How can I determine if a string is a local folder string or a network string?,
Get the drive letter from a path string or FileInfo and
How can I determine if a given drive letter is a local/mapped/usb drive?
So:
string path = "\\some-unc-path\file.txt"; // or: #"H:\file2.txt" for mapped network drives
if (new Uri(path).IsUnc)
{
// network
}
else
{
var fileInfo = new FileInfo(path);
var driveLetter = Path.GetPathRoot(fileInfo.FullName);
var driveInfo = new DriveInfo(driveLetter);
if (driveInfo.DriveType == DriveType.Network)
{
// network
}
}
just out of curiosity, would it be possible to tell if a network disc is a NAS programmatically?
No, that's the miracle of abstraction. You talk SMB to a device, it talks SMB back. Any device that can talk SMB can be on the other end, be it a Windows or Linux server, an desktop, a NAS, a SAN, heck, even routers and TVs talk SMB nowadays so you can plug in an USB drive and expose it over your home network.
You could detect a NAS by probing well-known ports where NASes are hosting extra services besides SMB, such as their (web) management interface and seeing what they return, but I wouldn't go there as I wouldn't know what problem that would solve.
This question already has answers here:
Request.UserHostAddress issue with return result "::1"
(4 answers)
Closed 9 years ago.
I have a login page where the user can login to my website when the user click on the submit button in the login page I want to read it's Ip address how ca i do this is c# I tried this
Request.UserHostAddress;
but the result was ::1 is it because I am logging in from the local machine or the statement that I used above is wrong?
That's basically the IPv6 version of 127.0.0.1 so is technically correct. If you don't use or need IPv6 disable it in the network adapter settings.
::1 is the IPv6 address, your code is correct.
See this answer for details.
This question already has an answer here:
Is there a way to specify the local port to used in tcpClient?
(1 answer)
Closed 9 years ago.
First off, I don't want to do this in production! I need to test whether someone else's implementation of a protocol on top of TCP is causing issues.
I want to use a certain outbound port over and over for multiple TCP sessions. Windows normally increments the port for each new session, and I want to circumvent this for testing. How can I set the outbound port of a TcpClient?
According to another post (Is there a way to specify the local port to used in tcpClient?). You need to use the constructor overload that takes an IPEndpoint in order to specify the local port to use.