Hello
In order to play a little bit with UDP frames I lauch 2 programms on
two machines:
rx:
/****************************************************************************/
#include <sys/types.h>
#include <linux/in.h>
#include <linux/net.h>
/****************************************************************************/
#define TEST_PORT 4094
int main(int argc,char **argv)
{
int Socket;
int Result;
int InBoundMessageCount=0;
int InBoundCharCount=0;
int BytesRx;
char Msg[1024];
char ch;
int Stop =0;
struct sockaddr_in Source;
Source.sin_family = AF_INET;
Source.sin_addr.s_addr = 0xC621518B;
Source.sin_port = htons (TEST_PORT);
//
//Open a socket
//
Socket = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if (Socket < 0)
{
printf("socket Error %d\n",Socket);
return 0;
}
while(Stop == 0 )
{
BytesRx = recvfrom(Socket,Msg,1024,MSG_PEEK ,&Source , sizeof(struct
sockaddr_in ));
if( BytesRx > 0)
{
InBoundMessageCount++;
InBoundCharCount += BytesRx;
printf("InBoundMessageCount %d InBoundCharCount
%d\r",InBoundMessageCount,InBoundCharCount);
}
else
printf("recvfrom Error %d\n",BytesRx);
ch = getchar();
if(ch == 'q')
Stop = 1;
}
//
//Clean up
//
close(Socket);
return 0;
}
and on the other side tx
tx:
/****************************************************************************/
#include <sys/types.h>
#include <linux/in.h>
#include <linux/net.h>
/****************************************************************************/
#define TEST_PORT 4094
int main(int argc,char **argv)
{
int Socket;
int Result;
int OutBoundMessageCount=0;
int OutBoundCharCount=0;
int BytesSent;
char Msg[1024];
char ch;
int Stop =0;
struct sockaddr_in Destination;
Destination.sin_family = AF_INET;
//Destination.sin_addr.s_addr = 0xC7215111;
Destination.sin_addr.s_addr = 0xC621518B;
Destination.sin_port = htons (TEST_PORT);
//
//Open a socket
//
Socket = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if (Socket < 0)
{
printf("socket Error %d\n",Socket);
return 0;
}
while(Stop == 0 )
{
BytesSent = sendto(Socket,Msg,1024,0 ,&Destination , sizeof(struct
sockaddr_in ));
if( BytesSent > 0)
{
OutBoundMessageCount++;
OutBoundCharCount += BytesSent;
printf("OutBoundMessageCount %d OutBoundCharCount
%d\r",OutBoundMessageCount,OutBoundCharCount);
}
else
printf("sendto Error %d\n",BytesSent);
ch = getchar();
if(ch == 'q')
Stop = 1;
}
//
//Clean up
//
close(Socket);
return 0;
}
The packet seems to be well transmited (i can see it in /proc/net/snmp)
As you can imagine nothing arrives...
The question .... why??
Thank you
Ciao
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]