Sponsored Content
Full Discussion: Why UDP broadcast don't run?
Top Forums UNIX for Advanced & Expert Users Why UDP broadcast don't run? Post 302266311 by konvalo on Wednesday 10th of December 2008 12:06:22 AM
Old 12-10-2008
Question Why UDP broadcast don't run?

I use FreeBSD7.0, I want to use UDP broadcast,my code is following:
/*udpcli01.c*/
int
main(int argc, char **argv)
{
int sockfd;
struct sockaddr_in servaddr;
if (argc != 2)
err_quit("usage: udpcli <IPaddress>");
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(13);
inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
sockfd = Socket(AF_INET, SOCK_DGRAM, 0);
dg_cli(stdin, sockfd, (SA *) &servaddr, sizeof(servaddr));
exit(0);
}

/*dg_cli.c*/
void
dg_cli(FILE *fp, int sockfd, const SA *pservaddr, socklen_t servlen)
{
int n;
char sendline[MAXLINE], recvline[MAXLINE + 1];
while (fgets(sendline, MAXLINE, fp) != NULL) {
sendto(sockfd, sendline, strlen(sendline), 0, pservaddr, servlen);
n = Recvfrom(sockfd, recvline, MAXLINE, 0, NULL, NULL);
recvline[n] = 0; /* null terminate */
fputs(recvline, stdout);
}
}

When I run above code,10.1.2.255 is broadcast address,and input a line,like following:
$./udpcli01 10.1.2.255
Hi

It should receive many machine response,but I don't receive any message!
If I ping 10.1.2.255,I can receive many machine response message,why my code can't receive message? How can I modify above code to receive message?

Thanks in advance!
 

8 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

broadcast

Can anybody hellp me troubleshoot this error. Using HP-Uxix B.10.X " *****ARPA/9000 NETWORKING***** Mon Jun 30 SAT 2003 20:18:12.xxxxxxx DISASTER Subsys: NS_LS_PROBE LOC:01001 Network NS_LS_PROBE DISASTER 1001, pid arp: ether address is broadcast for IP address zzzzzzz! " where... (1 Reply)
Discussion started by: SEB
1 Replies

2. Shell Programming and Scripting

Run expect script in systems that don't support it out of box

Noob question .. My Java based application needs to change some user passwords based on some user actions. Since this application can run on Redhat AS2.1 / AS4.0 / Solaris 9 etc, the most safe and portable solution that I could think of was: Use expect. Now, expect is not available on all... (1 Reply)
Discussion started by: namityadav
1 Replies

3. Programming

How to broadcast a message ?

My problem definition is ,I have to send a message from one node in a network and it has to be broadcasted to all other nodes in the network.The program what I have given below will be running in all the nodes in the network.The same program should be capable of sending(broadcasting) and receiving.... (0 Replies)
Discussion started by: vigneshinbox
0 Replies

4. IP Networking

how to do udp broadcast with multithreading

hello to all i want to use multithreading to my UDP broadcast server client program. will anyone help me by proving C code. i am working in fedora. also my requirement is POSIX compliance.please help me..... (0 Replies)
Discussion started by: moti12
0 Replies

5. Programming

how to do udp broadcast with multithreading

hello to all i want to use multithreading to my UDP broadcast server client program. will anyone help me by proving C code. i am working in fedora. also my requirement is POSIX compliance.please help me..... (6 Replies)
Discussion started by: moti12
6 Replies

6. Shell Programming and Scripting

Background processes in a pipeline don't run asynchronously?

I'm wondering about what causes this behavior. Mainly, given the first case below, why the second changes the behavior of ''&'' to execute sequentially merely because the command group containing calls to f() is part of a pipeline. The 4th example bizarrely once again works as the first, even with... (2 Replies)
Discussion started by: ormaaj
2 Replies

7. Shell Programming and Scripting

Nc won't send udp broadcast!?

Greetings, I want to send broadcast udp from a script. This works but is not broadcast: echo -n "this is my message\r\n" | nc -u 192.168.0.12 5100 The broadcast version does not work: echo -n "this is my message\r\n" | nc -u 192.168.0.255 5100 Suggestions on the right way to do this... (2 Replies)
Discussion started by: anotherstevest
2 Replies

8. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies
tapset::udp(3stap)														tapset::udp(3stap)

NAME
tapset::udp - systemtap udp tapset DESCRIPTION
This family of probe points is used to probe events that occur in the UDP layer. udp.sendmsg Fires whenever a process sends a UDP message See probe::udp.sendmsg(3stap) for details. udp.sendmsg.return Fires whenever an attempt to send a UDP message is completed See probe::udp.sendmsg.return(3stap) for details. udp.recvmsg Fires whenever a UDP message is received See probe::udp.recvmsg(3stap) for details. udp.recvmsg.return Fires whenever an attempt to receive a UDP message received is completed See probe::udp.recvmsg.return(3stap) for details. udp.disconnect Fires when a process requests for a UDP disconnection See probe::udp.disconnect(3stap) for details. udp.disconnect.return UDP has been disconnected successfully See probe::udp.disconnect.return(3stap) for details. SEE ALSO
probe::udp.sendmsg(3stap), probe::udp.sendmsg.return(3stap), probe::udp.recvmsg(3stap), probe::udp.recvmsg.return(3stap), probe::udp.disconnect(3stap), probe::udp.disconnect.return(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::udp(3stap)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy