[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: udpcat



..
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
memset(&sin, 0, sizeof(struct sockaddr_in));
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(MY_PORT_OF_CHOICE);
sin.sin_family = AF_INET;
bind(s, (struct sockaddr*)&sin, sizeof(struct sockaddr_in));
while( (nReceivedBytes = recvfrom(s, buf, maxlen, myflags, (struct
sockaddr*)&from_sin, sizeof(struct sockaddr) )) != -1 ) {
	WriteDataToFile(buf);
}
..

Yes, it's *that* simple.
Don't forget to check the return values of socket(), bind(), etc.

--
Uriel Ginsburg                                   Tel:    +972 9 9579797
Internet Projects Coordinator                    Fax:    +972 9 9579796
Universal Eagle Investment Banking, Ltd.         Email:
Uriel@universaleagle.com
--

-----Original Message-----
From: erez@savan.com [mailto:erez@savan.com]
Sent: Thursday, February 17, 2000 9:32 AM
To: ILUG
Subject: udpcat


hi

does anyone know a util that listens to a udp port, and sends the data
in the incoming packets
to a file ( or stdout )

regards
erez.


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il



=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il