RPi-Python: server(RPi) - client(Win PC) socket connection example

How to send 3 voltage measurement data from Raspberry Pi to Win PC notebook for
processing, graphing, etc. 

Pyton2 socket connection program part from server:

import sys import socket # ............socket................................................. HOST = '' # Symbolic name meaning all available interfaces PORT = 7227 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print 'Socket created' try: s.bind((HOST, PORT)) except socket.error , msg: print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1] sys.exit() print 'Socket bind complete' s.listen(10) print 'Socket now listening' # ............connection.............................................. #wait to accept a connection - blocking call conn, addr = s.accept() print 'Connected with ' + addr[0] + ':' + str(addr[1]) # .................................................................... Repetitive sending of 3 values concatenated into 1 string s012: while tmin < tgiv: # maximum minutes of running (v0,v1,v2) = bj.dm_pet(di,t1) # CALL: measuring and printing one line sv0, sv1, sv2 = str(v0), str(v1), str(v2) s012 = sv0 + ":" + sv1 + ":" + sv2 + "x" try : conn.sendall(s012) # .......send data to client.......... except socket.error: # ... print 'Send failed' # ... sys.exit() . . . Displayed: Socket created Socket bind complete Socket now listening Connected with 192.168.1.15:50585

Pyton2 socket connection program part from client:

import socket #for sockets import sys #for exit #create an INET, STREAMing socket try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: print 'Failed to create socket' sys.exit() print 'Socket Created' host = '192.168.1.17'; port = 7227; #Connect to remote server s.connect((host,port)) print 'Socket Connected to ' + host + ' on port ' + str(port) # ............................................................. Receiving string sv012 and extracting 3 values v0, v1, v2: while True: sv012 = s.recv(16) tm = tm + 1 if len(sv012) == 0: break if len(sv012) != 15: continue sv0, sv1, sv2 = sv012[0:4], sv012[5:9], sv012[10:14] v0, v1, v2 = int(sv0), int(sv1), int(sv2) . . . Displayed: Socket Created Socket Connected to 192.168.1.17 on port 7227