Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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)
{ ......

c¾²Ì¬±àÒëÁíÒ»¸öÎļþ¼ÐµÄ¿âº¯Êý - C/C++ / CÓïÑÔ

ÔÚ¸ùĿ¼/libÖдæ·ÅÒ»¸ölog.c£¬log.h£¬²¢ÓÃÏÂÃæµÄÓï¾ä£º
gcc -c log.c
ar crv liblog.a log.o
±àÒë³öÒ»¸öliblog.a¾²Ì¬¿â£¬È»ºóÔÚÎļþ¼Ð£º/testfileÖд´½¨Ò»¸ötest.cºÍtestc.c£¬test.cÖÐÒýÓÃÁËtestc.cÖж¨ÒåµÄ·½·¨ ......

ÇóÖú£ºC´úÂëchange toVB´úÂë - VB / »ù´¡Àà

ͦ·±Ëö£¬Ö®Ç°·¢µÄÌû×Ó£¬·Öֵ̫µÍÏÖÔÚÖØ·¢Ò»¸ö¡£»¶Ó­¸÷λ´óÏÀ~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......

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

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

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

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

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

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