how to do udp broadcast with multithreading


 
Thread Tools Search this Thread
Special Forums IP Networking how to do udp broadcast with multithreading
# 1  
Old 05-20-2011
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.....
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Help with multithreading

I take this question of the The Linux Programming Interface: A Linux and Unix System Programming page 652 exercise 30.1 I want someone to explain the under line statement because it sounds complex to me couldn't understand anything 30-1 Modify the program (thread_incr.c) so that each loop in... (3 Replies)
Discussion started by: fwrlfo
3 Replies

2. 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

3. 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

4. Programming

MultiThreading using Pthreads

Situation: i have multiple pthread_create calls like this: pthread_create(...., ThreadFunc1,.....); pthread_create(...., ThreadFunc2,.....); . . which i am using to create multiple threads.All the "ThreadFunc<i>" functions are actually calling same function "Receive" of a class using same... (3 Replies)
Discussion started by: Sastra
3 Replies

5. Shell Programming and Scripting

Multithreading program

Hi I need to insert 1million records into MySQL database, but it is taking lot of time as there is no bulk insert support. I want to spawn 10 processes which will insert 100k records each parallely. Can somebody help me with a example program to execute this task through shell scripting. (5 Replies)
Discussion started by: sach_roger
5 Replies

6. UNIX for Advanced & Expert Users

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;... (2 Replies)
Discussion started by: konvalo
2 Replies

7. UNIX for Advanced & Expert Users

multithreading in UNIX

Hi, Can you please give me a suitable reference to learn multithreading programming in C in UNIX? Thanks (3 Replies)
Discussion started by: naan
3 Replies

8. Programming

multithreading on OSX

Hi all, I have a query about multithreading. What I would like to do is, at the start of my main update() function, start a couple of threads in parallel, once they are all complete carry on with my main update function. void update() { thread1->update(); // fluid solver ... (3 Replies)
Discussion started by: memoid
3 Replies

9. Programming

Multithreading in Pro*C

:confused: Hi! I have created a Multhreaded Application in Pro*C (using pthreads) with about 5 Threads running simultaneously. The Application is basically to Update a Centralized Table in Oracle, which updates different rows in the Table (Each Thread updates different rows!). The... (16 Replies)
Discussion started by: shaik786
16 Replies
Login or Register to Ask a Question
udp(n)                                                           Tcl UDP extension                                                          udp(n)

__________________________________________________________________________________________________________________________________________________

NAME
udp - Create UDP sockets in Tcl SYNOPSIS
package require Tcl 8.2 package require udp 1.0 udp_open ?port? udp_conf sock host port udp_conf sock ?-myport? ?-remote? ?-peer? ?-broadcast bool? ?-ttl count? udp_conf ?-mcastadd groupaddr? udp_conf ?-mcastdrop groupaddr? udp_peek sock ?buffersize? _________________________________________________________________ DESCRIPTION
This package provides support for using UDP through Tcl. The package provides a new channel type and attempts to permit the use of packet oriented UDP over stream oriented Tcl channels. The package defined three commands but udp_conf should be considered depreciated in favour of the standard Tcl command fconfigure. COMMANDS
udp_open ?port? udp_open will open a UDP socket. If port is specified the UDP socket will be opened on that port. Otherwise the system will choose a port and the user can use the udp_conf command to obtain the port number if required. udp_conf sock host port udp_conf in this configuration is used to specify the remote destination for packets written to this sock. You must call this com- mand before writing data to the UDP socket. udp_conf sock ?-myport? ?-remote? ?-peer? ?-broadcast bool? ?-ttl count? In addition to being used to configure the remote host, the udp_conf command is used to obtain information about the UDP socket. -myport Returns the local port number of the socket. -remote Returns the remote hostname and port number as set using udp_conf sock host port. -peer Returns the remote hostname and port number for the packet most recently received by this socket. -broadcast ?boolean? UDP packets can listen and send on the broadcast address. For some systems a flag must be set on the socket to use broadcast. With no argument this option will return the broadcast setting. With a boolean argument the setting can be modified. -ttl ?count? The time-to-live is given as the number of router hops the packet may do. For multicast packets this is important in specify- ing the distribution of the packet. The system default for multicast is 1 which restricts the packet to the local subnet. To permit packets to pass routers, you must increase the ttl. A value of 31 should keep it within a site, while 255 is global. udp_conf ?-mcastadd groupaddr? udp_conf ?-mcastdrop groupaddr? tcludp sockets can support IPv4 multicast operations. To recieve multicast packets the application has to notify the operating sys- tem that it should join a particular multicast group. These are specified as addresses in the range 224.0.0.0 to 239.255.255.255. udp_peek sock ?buffersize? Examine a packet without removing it from the buffer. This function is not available on windows. EXAMPLES
# Send data to a remote UDP socket proc udp_puts {host port} { set s [udp_open] fconfigure $s -remote [list $host $port] puts $s "Hello, World" close $f } # A simple UDP server package require udp proc udpEventHandler {sock} { set pkt [read $sock] set peer [fconfigure $sock -peer] puts "$peer: [string length $pkt] {$pkt}" return } proc udp_listen {port} { set srv [udp_open $port] fconfigure $srv -buffering none -translation binary fileevent $srv readable [list ::udpEventHandler $srv] puts "Listening on udp port: [fconfigure $srv -myport]" return $srv } set sock [udp_listen 53530] vwait forever close $sock # A multicast demo. proc udpEvent {chan} { set data [read $chan] set peer [fconfigure $chan -peer] puts "$peer [string length $data] '$data'" if {[string match "QUIT*" $data]} { close $chan set ::forever 1 } return } set group 224.5.1.21 set port 7771 set s [udp_open $port] fconfigure $s -buffering none -blocking 0 fconfigure $s -mcastadd $group -remote [list $group $port] fileevent $s readable [list udpEvent $s] puts -nonewline $s "hello, world" set ::forever 0 vwait ::forever exit HISTORY
Some of the code in this extension is copied from Michael Miller's tcludp package. (http://www.neosoft.com/tcl/ftparchive/sorted/comm/tcludp-1.0/) Compared with Michael's UDP extension, this extension provides Windows sup- port and provides the ability of using 'gets/puts' to read/write the socket. In addition, it provides more configuration ability. Enhancements to support binary data and to setup the package for the Tcl Extension Architecture by Pat Thoyts. SEE ALSO
socket(n) KEYWORDS
networking, socket, udp COPYRIGHT
Copyright (c) 1999-2000 Columbia University; all rights reserved udp 1.0.7 udp(n)

Featured Tech Videos