Hi out there !
I hope someone can help me in this.
I am new to Winsock Programming, but now I have written an Applicatian
that should send an UDP packet. It is compiled without errors.
When I stat the Programm it outputs:
Winsock startet !
UDP Socket createt !
11 Bytes Data send !
Than the Firewall Allerts:
Outbound Connection
Port xxx
Remote IP: < IP adress provided by my Providert>
of Course, I allow this Connection...
Now there should be an Inbound connection Alert, but It isn't. I have
tried to grab the UDP PAcket - but there is simply no UDP PAcket to
Sniff. I have tried to send the packet to a friend - the same result -
nothing is reaching it's Destination.
sorry for my Bad English :-)
Help would be really Great !
Greetz,
Ole
Here's the code I have written:
#include <windows.h>
#include <winsock2.h>
#include <stdio.h>
int ini_Winsock(void);
int startWinsock(void);
int open_socket(int);
int send_data(void);
long rc;
SOCKET sock_1;
SOCKADDR_IN addr;
SOCKADDR_IN remoteAddr;
int remoteAddrLen;
char buf[256];
void main(void){
open_socket(1);
closesocket(sock_1);
WSACleanup();
}
int startWinsock()
{
rc=ini_Winsock();
if(rc!=0)
{
printf("Fehler: startWinsock, error code: %d\n",rc);
return 1;
}else{
printf("Winsock startet!\n");
}
return 0;
}
int ini_Winsock()
{
WSADATA wsa;
return WSAStartup(MAKEWORD(1,2),&wsa);
int open_socket(int option){Quote:}
startWinsock();
if (option == 1){
printf("einz ist der Fall");
sock_1=socket(AF_INET,SOCK_DGRAM,0);
if(sock_1==INVALID_SOCKET){
printf("Error the UDP Socket couldn't be Created \n");
}else {printf("UDP SOCKET Createt \n");}
}else if (option == 2){
printf("zwei ist der Fall");
}else if (option == 3){
printf("drei ist der Fall");
}
printf("%d", option);
send_data();
getch();
return 0;}
int send_data(){
addr.sin_family=AF_INET;
addr.sin_port=htons(2172);
addr.sin_addr.s_addr=inet_addr("212.6.79.173");
strcpy(buf,"Hallo Welt!");
rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
if(rc==SOCKET_ERROR)
{
printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
return 1;
}else{
printf("%d Bytes gesendet!\n", rc);
printf("%d\n", WSAGetLastError());
}
return 0;}