当前位置:首页 » 操作系统 » gethostbyname源码

gethostbyname源码

发布时间: 2022-03-02 10:51:00

⑴ gethostbyname()的源码

struct hostent* gethostbyname(const char *name)
{
err_t err;
ip_addr_t addr;
/* buffer variables for lwip_gethostbyname() */
HOSTENT_STORAGE struct hostent s_hostent;
HOSTENT_STORAGE char *s_aliases;
HOSTENT_STORAGE ip_addr_t s_hostent_addr;
HOSTENT_STORAGE ip_addr_t *s_phostent_addr[2];
/* query host IP address */
err = netconn_gethostbyname(name, &addr);
if (err != ERR_OK) {
LWIP_DEBUGF(DNS_DEBUG, (lwip_gethostbyname(%s) failed, err=%d , name, err));
h_errno = HOST_NOT_FOUND;
return NULL;
}

⑵ delphi2010下 gethostbyname的返回值始终是空,怎么解决

delphi 2010中的string默认是widestring,直接使用PAnsiChar转换会有问题的,你可以把url定义为AnsiString而不是string。

⑶ 高分求200行的c程序源代码!!

经典c程序100例==61--70

【程序61】
题目:打印出杨辉三角形(要求打印出10行如下图)
1.程序分析:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
2.程序源代码:
main()
{int i,j;
int a[10][10];
printf("\n");
for(i=0;i<10;i++)
{a[i][0]=1;
a[i][i]=1;}
for(i=2;i<10;i++)
for(j=1;j a[i][j]=a[i-1][j-1]+a[i-1][j];
for(i=0;i<10;i++)
{for(j=0;j<=i;j++)
printf("%5d",a[i][j]);
printf("\n");
}
}
==============================================================
【程序62】
题目:学习putpixel画点。
1.程序分析:
2.程序源代码:
#include "stdio.h"
#include "graphics.h"
main()
{
int i,j,driver=VGA,mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
for(i=50;i<=230;i+=20)
for(j=50;j<=230;j++)
putpixel(i,j,1);
for(j=50;j<=230;j+=20)
for(i=50;i<=230;i++)
putpixel(i,j,1);
}
==============================================================
【程序63】
题目:画椭圆ellipse
1.程序分析:
2.程序源代码:
#include "stdio.h"
#include "graphics.h"
#include "conio.h"
main()
{
int x=360,y=160,driver=VGA,mode=VGAHI;
int num=20,i;
int top,bottom;
initgraph(&driver,&mode,"");
top=y-30;
bottom=y-30;
for(i=0;i {
ellipse(250,250,0,360,top,bottom);
top-=5;
bottom+=5;
}
getch();
}
==============================================================
【程序64】
题目:利用ellipse and rectangle 画图。
1.程序分析:
2.程序源代码:
#include "stdio.h"
#include "graphics.h"
#include "conio.h"
main()
{
int driver=VGA,mode=VGAHI;
int i,num=15,top=50;
int left=20,right=50;
initgraph(&driver,&mode,"");
for(i=0;i {
ellipse(250,250,0,360,right,left);
ellipse(250,250,0,360,20,top);
rectangle(20-2*i,20-2*i,10*(i+2),10*(i+2));
right+=5;
left+=5;
top+=10;
}
getch();
}
==============================================================
【程序65】
题目:一个最优美的图案。
1.程序分析:
2.程序源代码:
#include "graphics.h"
#include "math.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdarg.h"
#define MAXPTS 15
#define PI 3.1415926
struct PTS {
int x,y;
};
double AspectRatio=0.85;
void LineToDemo(void)
{
struct viewporttype vp;
struct PTS points[MAXPTS];
int i, j, h, w, xcenter, ycenter;
int radius, angle, step;
double rads;
printf(" MoveTo / LineTo Demonstration" );
getviewsettings( &vp );
h = vp.bottom - vp.top;
w = vp.right - vp.left;
xcenter = w / 2; /* Determine the center of circle */
ycenter = h / 2;
radius = (h - 30) / (AspectRatio * 2);
step = 360 / MAXPTS; /* Determine # of increments */
angle = 0; /* Begin at zero degrees */
for( i=0 ; i rads = (double)angle * PI / 180.0; /* Convert angle to radians */
points[i].x = xcenter + (int)( cos(rads) * radius );
points[i].y = ycenter - (int)( sin(rads) * radius * AspectRatio );
angle += step; /* Move to next increment */
}
circle( xcenter, ycenter, radius ); /* Draw bounding circle */
for( i=0 ; i for( j=i ; j moveto(points[i].x, points[i].y); /* Move to beginning of cord */
lineto(points[j].x, points[j].y); /* Draw the cord */
} } }
main()
{int driver,mode;
driver=CGA;mode=CGAC0;
initgraph(&driver,&mode,"");
setcolor(3);
setbkcolor(GREEN);
LineToDemo();}

c语言/C++,用recv获取网页源代码,中文为什么是乱码 代码如下:

这种问题通常是你的代码在处理字符串是弄错了。。。
接收过来的内容应该没问题吧。。。。
只是显示的时候弄错了吧。。
仔细检查一下,中文字符占2个字节,指针头别弄错了,最后加上'\0'别加错位置。。。
如果英文字符都不可以正确显示的话,那可能是粘包。
还有是不是编码问题。

⑸ 代码编程——ping命令流程(图)

不是我写的,找的。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define WIN32_LEAN_AND_MEAN
#include <winsock.h>
#pragma comment(lib, "Wsock32.lib")

#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0

//#define ICMP_MIN 8 // minimum 8 byte icmp packet (just header)
#define ICMP_MIN (8 + 4) // minimum 8 byte icmp packet (just header + timestamp)

// IP header
typedef struct _tagX_iphdr
{
unsigned char h_len:4; // length of the header
unsigned char version:4; // Version of IP
unsigned char tos; // Type of service
unsigned short total_len; // total length of the packet

unsigned short ident; // unique identifier
unsigned short frag_and_flags; // flags

unsigned char ttl; // ttl
unsigned char proto; // protocol (TCP, UDP etc)
unsigned short checksum; // IP checksum

unsigned int sourceIP;
unsigned int destIP;
}XIpHeader;

// ICMP header
typedef struct _tagX_icmphdr
{
unsigned char i_type;
unsigned char i_code;
unsigned short i_cksum;
unsigned short i_id;
unsigned short i_seq;
unsigned long i_timestamp;
}XIcmpHeader;

//puclic code
//网际校验和生产算法
//网际校验和是被校验数据16位值的反码和(ones-complement sum)
unsigned short in_cksum(unsigned short* addr, int len)
{
int nleft = len;
int sum = 0;
unsigned short* w = addr;
unsigned short answer = 0;

while(nleft > 1) {
sum += *w++;
nleft -= 2;
}

if(nleft == 1) {
*(unsigned char*)(&answer) = *(unsigned char*)w;
sum += answer;
}

sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;

return (answer);
}

void fill_IcmpData(char *buf, int datasize)
{
if (buf)
{
char ch = 0;
char* icmpdata = buf + sizeof(XIcmpHeader);
fprintf(stdout, "(IcmpData)\r\n");
for (int i = 0; i < datasize; i++)
{
ch = 'A' + i%('z' - 'A');
*(icmpdata + i) = ch;
fprintf(stdout, "%c", ch);
}
fprintf(stdout, "\r\n");
}
}

void fill_IcmpHeader(char *buf, int datasize)
{
static unsigned short seq_no = 0;
XIcmpHeader *icmp_hdr = (XIcmpHeader *)buf;
if (icmp_hdr)
{
icmp_hdr->i_type = ICMP_ECHO;
icmp_hdr->i_code = 0;
icmp_hdr->i_cksum = 0;

icmp_hdr->i_id = (unsigned short)GetCurrentProcessId();

icmp_hdr->i_seq = seq_no++;

icmp_hdr->i_timestamp = (unsigned long)::GetTickCount();

icmp_hdr->i_cksum = in_cksum((unsigned short*)buf, sizeof(XIcmpHeader) + datasize);

fprintf(stdout, "(IcmpHeader)\r\n");
fprintf(stdout, "%02X%02X%04X\r\n", icmp_hdr->i_type, icmp_hdr->i_code, icmp_hdr->i_cksum);
fprintf(stdout, "%04X%04X\r\n", icmp_hdr->i_id, icmp_hdr->i_seq);
fprintf(stdout, "%08X\r\n", icmp_hdr->i_timestamp);
}
}

// decode
void decode_IpIcmp(char *buf, int size)
{
XIpHeader *ip_hdr = (XIpHeader *)buf;
unsigned short iphdrlen;
if (ip_hdr)
{
fprintf(stdout, "(IpHeader)\r\n");
fprintf(stdout, "%01X%01X%02X%04X\r\n", ip_hdr->version, ip_hdr->h_len, ip_hdr->tos, ip_hdr->total_len);
fprintf(stdout, "%04X%04X\r\n", ip_hdr->ident, ip_hdr->frag_and_flags);
fprintf(stdout, "%02X%02X%04X\r\n", ip_hdr->ttl, ip_hdr->proto, ip_hdr->checksum);

//iphdrlen = ip_hdr->h_len * 4; // number of 32-bit words *4 = bytes
iphdrlen = ip_hdr->h_len << 2; // number of 32-bit words *4 = bytes
fprintf(stdout, "(IcmpHeader)\r\n");
if (size < iphdrlen + ICMP_MIN)
{
fprintf(stdout, "Reply %d bytes Too few\r\n", size);
}
else
{
XIcmpHeader *icmp_hdr = (XIcmpHeader *)(buf + iphdrlen);

fprintf(stdout, "%02X%02X%04X\r\n", icmp_hdr->i_type, icmp_hdr->i_code, icmp_hdr->i_cksum);
fprintf(stdout, "%04X%04X\r\n", icmp_hdr->i_id, icmp_hdr->i_seq);
fprintf(stdout, "%08X\r\n", icmp_hdr->i_timestamp);

unsigned long timestamp = 0;

timestamp = (unsigned long)::GetTickCount();

timestamp -= icmp_hdr->i_timestamp;

struct sockaddr_in from;
from.sin_addr.s_addr = ip_hdr->sourceIP;

fprintf(stdout, "Reply %d bytes from: %s time<%d TTL=%d icmp_seq=%d\r\n",
size,
inet_ntoa(from.sin_addr),
timestamp,
ip_hdr->ttl,
icmp_hdr->i_seq
);
}
}
}

int main(int argc, char **argv)
{
int ret = 0;

WSADATA ws;
WSAStartup(0x0101,&ws);

int iIcmpDataSize = 0;
struct sockaddr_in dest,from;
unsigned int addr = 0;
struct hostent *hp;

char buffer[1024];
char recv_buffer[1024];

if(argc < 2)
{
fprintf(stderr, "Usage: %s [host|ip] [datasize]\r\n", argv[0]);
return 0;
}

if (argc > 2)
iIcmpDataSize = atoi(argv[2]);
if (iIcmpDataSize < 1 || iIcmpDataSize > 1024)
iIcmpDataSize = 10;

memset(&dest, 0, sizeof dest);
dest.sin_family = AF_INET;
hp = gethostbyname(argv[1]);
if (!hp)
addr = inet_addr(argv[1]);
if ((!hp) && (addr == INADDR_NONE))
{
fprintf(stderr,"Unable to resolve %s\r\n",argv[1]);
return 0;
}
if (hp != NULL)
memcpy(&(dest.sin_addr), hp->h_addr,hp->h_length);
else
dest.sin_addr.s_addr = addr;

int sockfd;
sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

fprintf(stdout, "XPing...\r\n");
for (int i = 0; i < 3; i++)
{
fprintf(stdout, "Echo...\r\n");
memset(buffer, 0, 1024);
fill_IcmpData(buffer, iIcmpDataSize);
fill_IcmpHeader(buffer, iIcmpDataSize);
XIcmpHeader *icmp_hdr = (XIcmpHeader *)buffer;
int iSendSize = sendto(sockfd, buffer, sizeof(XIcmpHeader) + iIcmpDataSize, 0, (struct sockaddr*)&dest, sizeof(dest));

fprintf(stdout, "Reply...\r\n");
memset(&from, 0, sizeof from);
memset(recv_buffer, 0, 1024);

int fromlen = sizeof(from);
int iRecvSize = recvfrom(sockfd, recv_buffer, 1024, 0, (struct sockaddr*)&from, &fromlen);

if (iRecvSize > 0)
decode_IpIcmp(recv_buffer, iRecvSize);
}

WSACleanup();

return ret;
}

⑹ gethostbyname源码在哪个目录

你所说的源代码是哪一部分的源代码?因为我们一般说的linux源码是指内核,这个在装好的系统里是没有的,你要下载才行。

⑺ c语言获取网页源码

这个不是c语言的问题,网页很明确的告诉这个文档已经搬到t.sina.com.cn。这是一个跳转网页,你手动复制weibo.sina.com到浏览器,你看会跳转到weibo.com/guide/welcome,c不会像浏览器那样跳转后再获取吧,除非你改下程序,但是可能要涉及到http协议了,学术浅薄,就不多讲,祝你好运!

⑻ C++高手来啊,对一个软件源码修改一个小地方:就是把填ip地址的地方修改成填域名也有效

嗯,这需要转换一下,可以用gethostbyname网络搜索杰迅网络

⑼ WSAAsyncGetHostByName()的简介

简述:
获得对应于一个主机名的主机信息.-异步版本.
#include <winsock.h>
HANDLE PASCAL FAR WSAAsyncGetHostByName (HWND hWnd,
unsigned int wMsg,const char FAR * name,char FAR * buf,
int buflen);
hWnd 当异步请求完成时,应该接收消息的窗口句柄.
wMsg 当异步请求完成时,将要接收的消息.
name 指向主机名的指针.
buf 接收hostent数据的数据区指针.注意该数据区必须大于hostent结构的大小.这是因为不仅Windows Sockets实现要用该数据区域容纳hostent结构,hostent结构的成员引用的所有数据也要在该区域内.建议用户提供一个MAXGETHOSTSTRUCT字节大小的缓冲区.
buflen上述数据区的大小.
注释:
本函数是gethostbyname()的异步版本,是用来获取对应于一个主机名的主机名称和地址信息.Windows Sockets的实现启动该操作后立刻返回调用方,并传回一个异步任务句柄,应用程序可以用它来标识该操作.当操作完成时,结果(若有的话)将会拷贝到调用方提供的缓冲区,同时向应用程序的窗口发一条消息.
当异步操作完成时,应用程序的窗口hWnd接收到消息wMsg. wParam参数包含了初次函数调用时返回的异步任务句柄.lParam的高16位包含着错误代码.该代码可以是winsock.h中定义的任何错误.错误代码为0说明异步操作成功.在成功完成的情况下,提供给初始函数调用的缓冲区中包含了一个hostent结构.为存取该结构中的元素,初始的缓冲区指针应置为hostent结构的指针,并一如平常地存取.
注意若错误代码为WSAENOBUFS,它说明在初始调用时由buflen指出的缓冲区大小对于容纳所有的结果信息来说太小了.在这种情况下,lParam的低16位含有提供所有信息所需的缓冲区大小数值.如果应用程序认为获取的数据不够,它就可以在设置了足够容纳所需信息的缓冲区后,重新调用WSAAsyncGetHostByName().(也就是大于lParam低16位提供的大小.)
错误代码和缓冲区大小应使用WSAGETASYNCERROR和WSAGETASYNCBUFLEN宏从lParam中取出.两个宏定义如下:
#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
使用这些宏可最大地提高应用程序源代码的可移植性.
返回值:
返回值指出异步操作是否成功地初启.注意它并不隐含操作本身的成功或失败.
若操作成功地初启,WSAAsyncGetHostByName()返回一个HANDLE类型的非0值,作为请求需要的异步任务句柄.该值可在两种方式下使用.它可通过WSACancelAsyncRequest()用来取消该操作.也可通过检查wParam消息参数,以匹配异步操作和完成消息.
如果异步操作不能初启,WSAAsyncGetHostByName()返回一个0值,并且可使用WSAGetLastError()来获取错误号.
评价:
Windows Sockets的实现使用提供给该函数的缓冲区来构造hostent结构以及该结构成员引用的数据区内容.为避免上述的WSAENOBUFS错误,应用程序应提供一个至少MAXGETHOSTSTRUCT字节大小的缓冲区.
关于Windows Sockets提供者的说明:
Windows Sockets的实现应保证消息能成功地传给应用程序.如果PostMessage()操作失败,Windows Sockets的实现必须重发该消息-只要窗口存在.
Windows Sockets的提供者在消息中组织lParam时应使用WSAMAKEASYNCREPLY宏.

⑽ 求windows下ping程序c源代码,模拟的ping也行,能编译通过就行,网上很多通不过

#pragma pack(4)
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
#define ICMP_MIN 8 // minimum 8 byte icmp packet (just header)
/* The IP header */
typedef struct iphdr {
unsigned int h_len:4; // length of the header
unsigned int version:4; // Version of IP
unsigned char tos; // Type of service
unsigned short total_len; // total length of the packet
unsigned short ident; // unique identifier
unsigned short frag_and_flags; // flags
unsigned char ttl;
unsigned char proto; // protocol (TCP, UDP etc)
unsigned short checksum; // IP checksum
unsigned int sourceIP;
unsigned int destIP;
}IpHeader;
//
// ICMP header
//
typedef struct _ihdr {
BYTE i_type;
BYTE i_code; /* type sub code */
USHORT i_cksum;
USHORT i_id;
USHORT i_seq;
/* This is not the std header, but we reserve space for time */
ULONG timestamp;
}IcmpHeader;
#define STATUS_FAILED 0xFFFF
#define DEF_PACKET_SIZE 32
#define MAX_PACKET 1024
#define xmalloc(s) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(s))
#define xfree(p) HeapFree (GetProcessHeap(),0,(p))
void fill_icmp_data(char *, int);
USHORT checksum(USHORT *, int);
void decode_resp(char *,int ,struct sockaddr_in *);
void Usage(char *progname){
fprintf(stderr,"Usage: ");
fprintf(stderr,"%s [data_size] ",progname);
fprintf(stderr,"datasize can be up to 1Kb ");
ExitProcess(STATUS_FAILED);
}
int main(int argc, char **argv){
WSADATA wsaData;
SOCKET sockRaw;
struct sockaddr_in dest,from;
struct hostent * hp;
int bread,datasize;
int fromlen = sizeof(from);
int timeout = 1000;
char *dest_ip;
char *icmp_data;
char *recvbuf;
unsigned int addr=0;
USHORT seq_no = 0;
if (WSAStartup(MAKEWORD(2,1),&wsaData) != 0){
fprintf(stderr,"WSAStartup failed: %d ",GetLastError());
ExitProcess(STATUS_FAILED);
}
if (argc <2 ) {
Usage(argv[0]);
}
sockRaw = WSASocket (AF_INET,
SOCK_RAW,
IPPROTO_ICMP,
NULL, 0,0);
if (sockRaw == INVALID_SOCKET) {
fprintf(stderr,"WSASocket() failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
bread = setsockopt(sockRaw,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,
sizeof(timeout));
if(bread == SOCKET_ERROR) {
fprintf(stderr,"failed to set recv timeout: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
timeout = 1000;
bread = setsockopt(sockRaw,SOL_SOCKET,SO_SNDTIMEO,(char*)&timeout,
sizeof(timeout));
if(bread == SOCKET_ERROR) {
fprintf(stderr,"failed to set send timeout: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
memset(&dest,0,sizeof(dest));
hp = gethostbyname(argv[1]);
if (!hp){
addr = inet_addr(argv[1]);
}
if ((!hp) && (addr == INADDR_NONE) ) {
fprintf(stderr,"Unable to resolve %s ",argv[1]);
ExitProcess(STATUS_FAILED);
}
if (hp != NULL)
memcpy(&(dest.sin_addr),hp->h_addr,hp->h_length);
else
dest.sin_addr.s_addr = addr;
if (hp)
dest.sin_family = hp->h_addrtype;
else
dest.sin_family = AF_INET;
dest_ip = inet_ntoa(dest.sin_addr);
if (argc >2) {
datasize = atoi(argv[2]);
if (datasize == 0)
datasize = DEF_PACKET_SIZE;
}
else
datasize = DEF_PACKET_SIZE;
datasize += sizeof(IcmpHeader);
icmp_data = xmalloc(MAX_PACKET);
recvbuf = xmalloc(MAX_PACKET);
if (!icmp_data) {
fprintf(stderr,"HeapAlloc failed %d ",GetLastError());
ExitProcess(STATUS_FAILED);
}
memset(icmp_data,0,MAX_PACKET);
fill_icmp_data(icmp_data,datasize);
while(1) {
int bwrote;
((IcmpHeader*)icmp_data)->i_cksum = 0;
((IcmpHeader*)icmp_data)->timestamp = GetTickCount();
((IcmpHeader*)icmp_data)->i_seq = seq_no++;
((IcmpHeader*)icmp_data)->i_cksum = checksum((USHORT*)icmp_data,
datasize);
bwrote = sendto(sockRaw,icmp_data,datasize,0,(struct sockaddr*)&dest,
sizeof(dest));
if (bwrote == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("timed out ");
continue;
}
fprintf(stderr,"sendto failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
if (bwrote < datasize ) {
fprintf(stdout,"Wrote %d bytes ",bwrote);
}
bread = recvfrom(sockRaw,recvbuf,MAX_PACKET,0,(struct sockaddr*)&from,
&fromlen);
if (bread == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("timed out ");
continue;
}
fprintf(stderr,"recvfrom failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
decode_resp(recvbuf,bread,&from);
Sleep(1000);
}
return 0;
}
/*
The response is an IP packet. We must decode the IP header to locate
the ICMP data
*/
void decode_resp(char *buf, int bytes,struct sockaddr_in *from) {
IpHeader *iphdr;
IcmpHeader *icmphdr;
unsigned short iphdrlen;
iphdr = (IpHeader *)buf;
iphdrlen = iphdr->h_len * 4 ; // number of 32-bit words *4 = bytes
if (bytes < iphdrlen + ICMP_MIN) {
printf("Too few bytes from %s ",inet_ntoa(from->sin_addr));
}
icmphdr = (IcmpHeader*)(buf + iphdrlen);
if (icmphdr->i_type != ICMP_ECHOREPLY) {
fprintf(stderr,"non-echo type %d recvd ",icmphdr->i_type);
return;
}
if (icmphdr->i_id != (USHORT)GetCurrentProcessId()) {
fprintf(stderr,"someone else's packet! ");
return ;
}
printf("%d bytes from %s:",bytes, inet_ntoa(from->sin_addr));
printf(" icmp_seq = %d. ",icmphdr->i_seq);
printf(" time: %d ms ",GetTickCount()-icmphdr->timestamp);
printf(" ");
}
USHORT checksum(USHORT *buffer, int size) {
unsigned long cksum=0;
while(size >1) {
cksum+=*buffer++;
size -=sizeof(USHORT);
}
if(size ) {
cksum += *(UCHAR*)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (USHORT)(~cksum);
}
/*
Helper function to fill in various stuff in our ICMP request.
*/
void fill_icmp_data(char * icmp_data, int datasize){
IcmpHeader *icmp_hdr;
char *datapart;
icmp_hdr = (IcmpHeader*)icmp_data;
icmp_hdr->i_type = ICMP_ECHO;
icmp_hdr->i_code = 0;
icmp_hdr->i_id = (USHORT)GetCurrentProcessId();
icmp_hdr->i_cksum = 0;
icmp_hdr->i_seq = 0;
datapart = icmp_data + sizeof(IcmpHeader);
//
// Place some junk in the buffer.
//
memset(datapart,'E', datasize - sizeof(IcmpHeader));
}

估计你也试过,网上搜到的。

热点内容
安卓如何投屏奔驰 发布:2024-09-23 06:25:25 浏览:463
win服务器转发ip 发布:2024-09-23 06:15:27 浏览:570
macbook照片怎么放入安卓 发布:2024-09-23 06:03:08 浏览:406
关系型数据库的原理 发布:2024-09-23 05:58:34 浏览:576
商城模板html源码 发布:2024-09-23 05:58:31 浏览:342
我的世界最新好玩儿的服务器 发布:2024-09-23 05:41:04 浏览:593
编译时类型 发布:2024-09-23 05:39:30 浏览:316
脚本运行游戏卡顿 发布:2024-09-23 05:24:56 浏览:781
唱吧照片上传不了 发布:2024-09-23 05:18:42 浏览:79
java7并发 发布:2024-09-23 05:18:41 浏览:285