I am writing a program that uses network sockets. I need to know what the computer's IP address is, so I can display it in the user. Programs must be run on Windows and Linux.
I have heard somewhere that a computer can have multiple IP addresses. I should do this to use other programs of other computers to connect to the computer.
Here is the corresponding code that is already (Variables in other places are declared):
Master = new fd_set; FD_ZERO (master); Struct sockaddr_in my_addr; Audience = socket (PF_INET, SOCK_STREAM, 0); My_addr.sin_family = AF_INET; My_addr.sin_port = htons (port); My_addr.sin_addr.s_addr = INADDR_ANY; Memmets (my_addr.sin_zero, '\ 0', size my_addr.sin_zero); Tie (listener, (Structured Socder *) and my_edder, size my_addr); Listen (listener, 10); FD_SET (listener, master); FDX = listener;
I have heard somewhere that a computer can have multiple IP addresses I want to do that other computers can use other programs to connect to the computer.
Good ... this can be none of them. If a computer has multiple IP addresses, one of them can be accessed. Of course, one of them may be subject to different firewall rules or they can be on two completely different segments, but there is no way to detect any of these other circumstances.
Comments
Post a Comment