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
ÄÜ˵¾ßÌåµãºÃÂð!
ÊÔÁËÏÂmsdnÉÏÃæµÄÀý×Ó£¬¹ûȻҲ²»ÐÐ
È»ºóÔÚmsdnÉÏ¿´µ½ÁËÕâÑùµÄ»°
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
ÔÚ¸ùĿ¼/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Öж¨ÒåµÄ·½·¨ ......
ͦ·±Ëö£¬Ö®Ç°·¢µÄÌû×Ó£¬·Öֵ̫µÍÏÖÔÚÖØ·¢Ò»¸ö¡£»¶Ó¸÷λ´óÏÀ~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......
ÔھƵê¹ÜÀíϵͳÖÐ,ÓÐÒ»¸ö¶ÔÄÚµÄϵͳ,¹©Ç°Ì¨·þÎñÔ±ºÍ¾ÀíʹÓÃ
»¹ÓÐÒ»¸ö¾ÍÊǶÔÍâ,Èÿͻ§¿ÉÒÔÔÚÍøÉÏÔ¤¶©·¿¼ä,
ËüÃÇÖ®¼äÊÇÔõôͨѶµÄ.?µ±ÎÒÌá½»Ô¤¶©·¿¼äÐÅÏ¢µÄʱºò,
ÔÚ¶ÔÄÚµÄϵͳÖÐ,ÈçºÎÖªµÀÎÒÒѾÌá½»ÁËÐÅÏ¢¹ýÈ¥.Ê¹Ç ......
ÏÖÓÐparadoxÊý¾Ý¿âʹÓÃBDEÇý¶¯£¬Äâ¸ÄΪC/S°æ£¬Ôö¼ÓÍøÂç¶ÁÈ¡Êý¾Ý¹¦ÄÜ¡£ÇëÄÄλ´óÏÀ£¬ÌṩԴÂë¡£
˵¾ä²»¿ÍÆøµÄ»°£¬ÓÃparadox×öC/SÊÇ×ÔÑ°ËÀ·¡£
»»Ò»¸öÍøÂçÊý¾Ý¿â
ÒòΪ²»Ï붯´óÊÖÊõ£¬½öÄܹ²Ïí¼¸¸öÎļþ¼´¿É¡£
Da ......