1

I have this program running on my RPi(sudo ais_rx.tcp -d --tcp):

https://github.com/chgans/gr-ais

I have gotten it running and can create an output file. I can not get the TCP server option to function. Netstat --tcp shows nothing. Telnet in...connection refused. I think maybe there is a code error:

conns = [] #active connections
if options.tcp is True:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('', 9987))
    s.listen(1)
    s.setblocking(0)
try:
    while 1:
        if options.tcp is True:
            try:
                conn, addr = s.accept()
                conns.append(conn)
                print "Connections: ", len(conns)
            except socket.error:
                pass

        if not queue.empty_p():
            while not queue.empty_p():
                msg = queue.delete_head() # Blocking read
                sentence = msg.to_string()
                if options.tcp is True:
                    for conn in conns[:]:
                        try:
                        conn.send(sentence + "\n")
                        except socket.error:
                        conns.remove(conn)
                            print "Connections: ", len(conns)
                else:
                    print sentence
                    sys.stdout.flush()

        elif runner.done:
            if options.tcp is True:
                s.close()
            break
        else:
            time.sleep(0.1)

The only other error i can think of is that if there is no data(which there isnt in my office) then the socket is never binded. I have tried manually typing in the ip in quotes, out of quotes, assigning it a variable... If it doesnt connect till data is available how would i change that? I'm thinking of removing:

if not queue.empty_p():
            while not queue.empty_p():

that way it does the other stuff whether there is data in the queue or not?? Im just taking random guesses at this point. THANKS. Any help would be greatly appreciated.

LrakWortep
  • 217
  • 1
  • 4
  • 15
  • I dont think I am ever reaching the TCP server section of the code. I entered in a bunch of print statements and they never show up the last print statement recieved is 'code' tb = my_top_block(options, queue) '/code' More lost than I was yesterday – LrakWortep Feb 12 '13 at 18:12

0 Answers0