socket使用AF_INET协议族,并创建SOCK_RAW原始套结字,自己填写IP头和TCP头,就当熟悉下头部结构吧。
* =====================================================================================
*
* Filename: raw.c
*
* Description: 使用原始套接字发送TCP协议,并外带自己的数据。
*
* Version: 1.0
* Created: 2012年09月11日 10时39分00秒
* Revision:
* Compiler: GCC
*
* Author: yadon.z
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#define DATA "hello"
#define PACKET_SIZE sizeof(struct iphdr) + sizeof(struct tcphdr) + sizeof(DATA)
/*--------------------------