Hi,
i wrote the socket script in python, Here both server and client running in under same machine. operating system is ubuntu 8.10 desktop version.
tcp server
1 #!/usr/bin/env python
2
3 import socket
4 import sys
5
6 server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
7 server_socket.bind(("", 5000))
8 server_socket.listen(5)
9 while 1:
10 client_socket, address = server_socket.accept()
11 print "I got a connection from ", address
12 line = client_socket.recv(1024)
13 print line
tcp client:
1#!/usr/bin/env python
2 import socket
3 import sys
4 import time
5 from subprocess import Popen, PIPE
6
7 #create socket object called client_socket
8 client_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
9 #Connect to the socket
10 client_socket.connect(("localhost",5000))
11 while 1:
12 #get the data from port 2947, using pipe concept
13 gpsreceiver = Popen('telnet localhost 2947',shell=True, stdout=PIPE)
14 while True:
15 #read data from port 2947, line by line
16 linedata = gpsreceiver.stdout.readline()
17 client_socket.send(linedata)
18 print linedata
Above script is get data from port 2947 and send that data to server tcp
Steps:
1. ./tcpserver.py (server file executed)
its waitng for client connection and opened the port 5000
2. ./tcpclient.py (client file executed)
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^
here, tcpserver log is: I got a connection from ('127.0.0.1', 33511)
Trying 127.0.0.1...
Then i need to type r and press enter in client file
r(pressed enter then the below data is printing client side)
GPSD,R=1
$GPRMC,235959,V,0000.0000,S,00000.0000,W,0.0000,0.000,311269,,*3A
$GPRMC,235959,V,0000.0000,S,00000.0000,W,0.0000,0.000,311269,,*3A
$GPRMC,235959,V,0000.0000,S,00000.0000,W,0.0000,0.000,311269,,*3A
-
-
-
-
But in server side no improment
I got a connection from ('127.0.0.1', 33511)
Trying 127.0.0.1...This means starting line is send to server script but after that its not sending
In the above r is for getting data in raw mode and dont consider about the generated values...because i connected my gps inside room...if connect it in outside then it will give the correct values.
Here, the task is gps data is getting from the port 2947 and sending to server side. Before testing in different..i tried in same machine but its not working properly....Please clarify it.
Thanks,