source: ETALON/BPM/writeclient_noreply.py

Last change on this file was 761, checked in by delerue, 6 years ago

Added writeclient_noreply.py to the BPM

File size: 878 bytes
Line 
1#small client based on the matlab function writeclient
2__author__ = 'delerue'
3
4import time
5from datetime import datetime
6
7# Echo client program
8def writeclient_noreply(HOST,PORT,msg,verbose,waittime=0,logfile='',datedlog=''):
9    "Writes msg on host HOST port PORT; verbose if verbose=1"
10    import socket
11    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12    s.connect((HOST, PORT))
13    if (verbose==1):
14        print 'Sending message ', msg, ' to host ', HOST, ' on port ', PORT
15    if (datedlog!=''):
16        date_str=datetime.now().strftime("_%Y%m%d")
17        logfile=datedlog+date_str+".txt"
18    if (logfile!=''):
19        f = open(logfile, 'a')
20        time_str=datetime.now().strftime("%Y%m%d %H:%M:%S")
21        f.write("("+time_str+") > "+msg+"\n")
22    s.sendall(msg)
23
24#writeclient('127.0.0.1',50007,'Hello',1,datedlog='/Users/delerue/Downloads/writeclient_tmp')
Note: See TracBrowser for help on using the repository browser.