将UDP报文分解,加序号,然后发送的。编译时有很多语法错误,望各位老虾指出错误,小弟不胜感激
#include
#include
#include
#include
#include
#include
#include
#include
#define PORT 4321
#define LEN 50
#define MAXLINE 1024
#define NUM 6
int main(int argc,char* argv)
{
int socketfd;
struct sockaddr_in addr;
bzero(&addr,siziof(addr));
addr_sin_family = AF_INET;
addr.sin_port=htons(PORT);
inet_pton(AF_INET,argv[1],&addr,sin_addr);
if((sockfd=socket(AF_INET,SOCK_DGRAM,0))<0)
{
perror("socket error");
exit(1);
}
dg_porta(stdlin, sockfd, (struct sockaddr *)&addr, sizeof(addr));
exit(0);
}
void dg_porta(FILE *fp, int sockfd, (const struct sockaddr)*paddr, socklen_t len )
{
char sendline[MAXLINE];
int n;
while(fgets(sendline,MAXLINE,fp)!=NULL)
{
n= strlen (sendline);
if(n<=LEN)
sendto(sockfd, sendline, n, 0, paddr, len ));
else
{
printf("the buffer is lager,fragment is needed\n");
fragment(sendline, sockfd, (const struct sockaddr)*paddr, socklen_t len );
}
}
}
void fragment(char* pBuffer, int fd,(const struct sockaddr)*paddr, socklen_t len )
{
unsigned char aa[NUM-1];
memset((void*) aa, 0X00, sizeof(unsigned char)*6);
char gp[LEN];
char* data;
while(pBuffer)
{
int j=0;
bzero(data,sizeof(data));
unsigned char or=sequence(aa);
unsigned char order=htons(or);
strcpy(data[j],oder);
for(pBuffer,i=0; i, sizeof(pdata), 0, (const struct sockaddr)*paddr, socklen_t len );
}
void not_order(char* pdata, int m, int fd, (const struct sockaddr)*psddr, socklent_t len)
{
randomize();
for(int i=0; i |