Hey...
I recently worked with the HelloWorld and Client demo and got it to work. Receiving and echoing back packets over ethernet works well! Now I want to send packets to my host PC anywhere in my project code, and not only in the deamon call back, where incoming packets are received from the PC. For this, I create a socket, and send out the packets: I see traffic on my ethernet switch, but the packets do not appear in my wireshark session!!!
What am I doing wrong??
SOCKET s;
struct sockaddr_in sin1;
struct sockaddr_in sin2;
int i,tmp,test;
char *pBuf = "Haba dere!";
UINT32 buffersize = 11;
struct timeval timeout;
HANDLE hBuffer;
/* Allocate the file environment for this task */
fdOpenSession( TaskSelf() );
// Create test socket
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if( s == INVALID_SOCKET ) {
printf("failed socket create (%d)\n",fdError());
goto leave;
}
// Bind socket
bzero( &sin1, sizeof(struct sockaddr_in) );
if( bind( s, (PSA) &sin1, sizeof(sin1) ) < 0 ) {
printf("failed bind (%d)\n",fdError());
goto leave;
}
// Prepare address for the SendTo
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_len = sizeof( sin1 );
sin1.sin_addr.s_addr = inet_addr(IPAddr);
sin1.sin_port = htons(7);
// Configure our timeout to be 5 seconds
timeout.tv_sec = 5;
timeout.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
while(1) {
if( sendto( mysocket, mypBuf, buffersize, 0,(PSA)&mysin1, sizeof(mysin1) ) < 0 ) {
printf("send failed (%d)\n",fdError());
break;
}
else {
printf("send successful !\n");
}
}