This is a small client-server program in which i am using a Vbscript program
to check for connectivity of 2 machines and write the output to a text file
whether it connectes or not ,


for example the contents of the file *output.txt* are

192.168.1.2 is connected
192.168.1.10 is not connected


Now i am trying to send the contents of this file from a client through a
socket to a server which is running on my main server .This is basically
created to automate the checking of connectivity of the machines. The issue
is that although the Vbscript writes the output to the file correctly but
when the client sends the contents of the file to the server via socket , it
sometimes prints all the lines of the file on the server and sometimes it
doesnt , i dont know whether the issue is with the client or the server ,
Please Help..


CLIENT.PY

import socket
import os
import sys
os.system("C:\Python26\ping.vbs")
host = "localhost"
port= 23333
size = 1024

s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))




f=open('output.txt','r')
while 1:
data = f.readline()
if data: s.send(data)
 else: break



f.close()

s.close()



SERVER.PY


import socket

host = ""
port = 23333
size = 1024
backlog=5
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.bind((host,port))
s.listen(backlog)

while 1:
client, addr =s.accept()
data=client.recv(size)
if data:
print data

else:
print  "client exit"

s.close()









-- 
Regards
Aditya
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to