Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ ͨ¹ýÔ¶¶ËIPÈçºÎ»ñµÃ¼ÆËã»úÃû

ÎÒ×öµÄ

#include <winsock2.h>
#include <stdio.h>
#pragma comment(lib,"ws2_32.lib")
void main()
{
WSADATA wsadata;
WORD dwVersionRequested;
int err;
dwVersionRequested=MAKEWORD(1,1);
err=WSAStartup(dwVersionRequested,&wsadata);

unsigned int addr;
char *myIp= "192.168.1.100"; //²»ÊDZ¾»úIP
addr = inet_addr(myIp);
struct hostent *pHost1 = gethostbyaddr((char *)&addr,4,PF_INET);

printf("%s\n",pHost1->h_name);//¼ÆËã»úÃû×Ö

WSACleanup();
}


Õâ¸ö´ò³öÀ´µÄÊÇ¡°localhost¡±ÎªÊ²Ã´²»ÊÇÄÇIPµÄ¼ÆËã»úÃû???
Èç¹ûmyIpÊDZ¾»úIP¿ÉÒÔ´ò³ö±¾»úÃû¡£


Õâ¸ögethostbyaddrÔõôµÃµ½Ô¶¶ËIPµÄ¼ÆËã»úÃû£¬»¹ÓÐûÓÐÆäËü·½·¨Í¨¹ýÔ¶¶ËIP»ñµÃ¸ÃIP¼ÆËã»úÃû£¿£¿£¿£¨ÒªÔ¶¶ËIPµØÖ·µÄ¼ÆËã»úÃû²»Òª±¾µØµÄ£©
ÄãµÄ³ÌÐòûÎÊÌ⣬¹À¼ÆÊÇÄãµÄIPµÄÎÊÌâ°É

ÊÇѽ£¬Õâ¸öÖ»Äܵõ½±¾µØIPµØÖ·µÄ¼ÆËã»úÃû£¬ÎÒÏëÒªÔ¶¶ËIP»ñµÃ¸ÃIP¼ÆËã»úÃû.....

Ô¶³ÌÄÜͨÂð

Ô¶³ÌÄÜͨ,ping¶¼ÄÜͨ

Õâ¾ÍÊÇÔ¶¶ËµÄIP¡¡¡¡char *myIp= "192.168.1.100"; //²»ÊDZ¾»úIP
ËüµÃµ½µÄÊÇ"localhost¡±

Õâ¸öÒªÊDZ¾»úIP¾Í¿ÉÒԵõ½±¾»ú¼ÆËã»úÃû



mark

ÒýÓÃ
mark



ÄÜ˵¾ßÌåµãºÃÂð!

ÊÔÁËÏÂmsdnÉÏÃæµÄÀý×Ó£¬¹ûȻҲ²»ÐÐ

È»ºóÔÚmsdnÉÏ¿´µ½ÁËÕâÑùµÄ»°


Ïà¹ØÎÊ´ð£º

linux»·¾³ÏÂgethostbynameº¯ÊýÎÊÌâ - C/C++ / CÓïÑÔ

дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
   
  struct hostent *hp; 
char AlarmDevIP[20];  
  int x2;

hp = gethostbyname("www.google.com");
if (hp)
{ ......

VFPÈçºÎµ÷ÓÃCº¯Êý - ÆäËûÊý¾Ý¿â¿ª·¢ / VFP

ÇëÎÊVFPÖÐÈçºÎµ÷ÓÃC/C++º¯Êý£¿

ÄãÒªµ÷ÓÃʲô¹¦Äܵĺ¯Êý£¿Òª¿´¿´VFPÖÐÓÐûÓжÔÓ¦µÄº¯Êý£¬Èç¹ûÓоÍÊ¡×ÅÔÙµ÷ÓÃÁË¡£Èç¹ûûÓУ¬¿ÉÒÔ½«C/C++º¯Êýд¸öDLL»òFLL£¬È»ºóÔÚVFPµ÷Óü´¿É¡£

Ê®¶¹Èý ÀÏʦ£¬Ôõô²ÅÄÜÐÞ¸Ä×Ô¼ºµÄ ......

c# Winform ´¥ÃþÆÁ³ÌÐò - .NET¼¼Êõ / C#

¹«Ë¾¿ª·¢Ò»¸ö´¥ÃþÆÁ³ÌÐò£¬ÎÒ¸ºÔðµÄÒ»¿é£¬ÊµÏÖÕâÑùÒ»¸ö¹¦ÄÜ£¬µ±Êó±êµã»÷´°¿ÚÖÐͼƬ£¨Ò»ÕÅͼ·Ö³É¼¸²¿·Ö£©µÄÆäÖÐÒ»²¿·Öʱ£¬½«Õⲿ·ÖͼƬ½ØÈ¡³öÀ´£¬µ¯³öеĴ°¿Ú£¬½«½ØÈ¡³öµÄͼƬÏÔʾ³öÀ´¡£ÎÒʹÓÃRectangeÀà¿ØÖÆÁË·µ»Ø£¬ ......

c/sºÍb/sÖ®¼äÔõôͨѶ. - Java / Web ¿ª·¢

ÔھƵê¹ÜÀíϵͳÖÐ,ÓÐÒ»¸ö¶ÔÄÚµÄϵͳ,¹©Ç°Ì¨·þÎñÔ±ºÍ¾­ÀíʹÓÃ
»¹ÓÐÒ»¸ö¾ÍÊǶÔÍâ,Èÿͻ§¿ÉÒÔÔÚÍøÉÏÔ¤¶©·¿¼ä,
ËüÃÇÖ®¼äÊÇÔõôͨѶµÄ.?µ±ÎÒÌá½»Ô¤¶©·¿¼äÐÅÏ¢µÄʱºò,
ÔÚ¶ÔÄÚµÄϵͳÖÐ,ÈçºÎÖªµÀÎÒÒѾ­Ìá½»ÁËÐÅÏ¢¹ýÈ¥.Ê¹Ç ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ