Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÉÏ¿´µ½ÁËÕâÑùµÄ»°


Ïà¹ØÎÊ´ð£º

C/C++ÖÐÓÐûÓиñʽ»¯UÅ̵ĺ¯Êý - C/C++ / C++ ÓïÑÔ

´ó¼ÒºÃ£º
ÎÒÏëʵÏÖ¼ì²âµ½²åÈëSD¿¨ºó×Ô¶¯½«SD¿¨¸ñʽ»¯µÄ¹¦ÄÜ£¬²»ÖªC/C++ÖÐÓÐûÓиñʽ»¯UÅ̵ĺ¯Êý£¿
ÁíÍ⣬ÎÒ²»ÏëʹÓÃSHFormatDrive£¬ÒòΪÕâ¸öº¯Êý»áµ¯³öÊÇ·ñÒª¸ñʽ»¯µÄÌáʾ¿ò£¬ÎÒÐèÒªµÄÊÇϵͳ×Ô¶¯¸ñʽ»¯£¬¶ø²Ù×÷Õß² ......

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

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

¸ÕѧÍêCµÄ»ù´¡£¬ÇóÏÂÒ»²½ - C/C++ / CÓïÑÔ

ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë 
Äã²»Àí½âÖ ......

¿ÄÇóC/SÔ´Âë - Delphi / Êý¾Ý¿âÏà¹Ø

ÏÖÓÐparadoxÊý¾Ý¿âʹÓÃBDEÇý¶¯£¬Äâ¸ÄΪC/S°æ£¬Ôö¼ÓÍøÂç¶ÁÈ¡Êý¾Ý¹¦ÄÜ¡£ÇëÄÄλ´óÏÀ£¬ÌṩԴÂë¡£
˵¾ä²»¿ÍÆøµÄ»°£¬ÓÃparadox×öC/SÊÇ×ÔÑ°ËÀ·¡£
»»Ò»¸öÍøÂçÊý¾Ý¿â

ÒòΪ²»Ï붯´óÊÖÊõ£¬½öÄܹ²Ïí¼¸¸öÎļþ¼´¿É¡£

Da ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ