[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
PROGRAM TO SEND DGRAMS
#include<stdlib.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include"header.h"
#define PORT 6000
struct sockaddr_in serv_addr;
int main()
{
int sockfd=0,count=0;
char buff[128];
printf("sender running\n");
serv_addr.sin_family=AF_INET;
serv_addr.sin_addr.s_addr=inet_addr("127.0.0.1");
serv_addr.sin_port=htons(PORT);
sockfd=socket(AF_INET,SOCK_DGRAM,0);
printf("\n %d ",sizeof(struct ip));
for(;;)
{
count=read(0,buff,sizeof(buff));
sendto(sockfd,(char *)buff,count,0,(struct sockaddr *)&serv_addr,
sizeof(serv_addr));
}
}