discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] GNU Radio TCP


From: Eric Blossom
Subject: [Discuss-gnuradio] GNU Radio TCP
Date: Wed, 9 Feb 2005 15:38:35 -0800
User-agent: Mutt/1.5.6i

I've received some questions about using TCP or UDP with GNU Radio 2.x.

Here's the low down:  You can set it all up from Python using the
socket module, and then hand the socket file descriptor off to
gr.file_descriptor_source or gr.file_descriptor_sink as appropriate.

Here's an example that connects to an SMTP mail server, prints the
banner then hangs  [Enter ^\ to quit].

----------------------------------------------------------------

#!/usr/bin/env python

from gnuradio import gr
import socket

def main ():
    item_size = 1
    fg = gr.flow_graph ()
    s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
    s.connect (('comsec.com', 25))
    src = gr.file_descriptor_source (item_size, s.fileno ())
    dst = gr.file_descriptor_sink (item_size, 1)
    fg.connect (src, dst)
    fg.run ()

if __name__ == '__main__':
    main ()

----------------------------------------------------------------


N.B., this example requires the CVS version of gr.file_descriptor_source.
I rewrote it today such that it returns as soon as it's got any data.
This makes it much friendlier for apps that read from sockets, named
pipes, etc.  The old version blocked until it had received all the
data request by the scheduler.

Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]