sockets - Read GPS incoming data in python -


i'm developing python script reads port , print answer. idea data gps.

this code i'm using.

#!/usr/bin/env python import socket host = ''       # ip address port = 5000    # pick port want listen on.  backlog = 5     # number of clients handle @ once size = 1024     # max size of data packet  # create socket: s = socket.socket(socket.af_inet, socket.sock_stream) # connect host / port: s.bind((host,port)) # start listening: s.listen(backlog) print "listening on: " + str(port) # stay in loop until ctrl-c typed @ console: while 1:     client, address = s.accept()     data = client.recv(size)     if data:         print data          # echo data console         client.send(data)   # echo data client (may confuse application, great browser)     client.close() 

now can connect via telnet , send message, i'll output in server. can connect via http: // [ip] : [port] , output. cannot information gps, although online, , i've re checked configuration. i've tried other devices. no luck.

my question is: missing here?

threading needs imported.

you need s. write data , def run script.

the code should this:

from threading import * class client(thread):   def __init__(self, socket, address):       thread.__init__(self)       s.sock = socket       s.addr = address   s.start() def run(self)     while 1:     data = s.client.recv(size)     print ('send data:' data)     self.sock.send(b'sending')  serversocket.listen(5) print ('server start listing') while 1:      clientsocket, address = serversocket.accept()      client(clientsocket, address) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -