Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get local IP address

Status
Not open for further replies.

JimmyK

Programmer
Sep 8, 2000
142
VN
Hello,
I have a small program like this
Code:
struct sockaddr_in local, from; 
WSADATA wsaData; 
SOCKET listen_socket, msgsock;  

//...
local.sin_family = AF_INET; 
local.sin_addr.s_addr = INADDR_ANY;
local.sin_port = htons(port);  
listen_socket = socket(AF_INET, socket_type,0); 
bind(listen_socket,(struct sockaddr*)&local,sizeof ocal) )  

char* myip;
myip = inet_ntoa(local.sin_addr);
But myip ="0.0.0.0"

How can i get my computer IP?

Thanks i advance

JIMMY




[sig][/sig]
 
Thanks Pete,
happy.gif


It helps, but i've already known. I wonder why after i "bind" , local.sin_addr is not my local IP

Jimmy
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top