i have a python code
i need it in c/c++ with feu improovement
a) if it disconnects out of ane reason the program should try to connect again
b) the program should be able to send computer name, internal IP and a string stored in the 10 first places of text file in specified location(if no file - send string "no zzz file"
thats all
## Deliverables
here is the source in python
from server import *
import select
import sys
import os
import ConfigParser
import time
reconnect_interval = 30
echo_interval = 30
echo_timeout = echo_interval * 2 + 10
def log(text):
print text
def start():
path = [login to view URL]([login to view URL]([login to view URL]), '[login to view URL]')
config = [login to view URL]()
[login to view URL](path)
# getfloat() raises an exception if the value is not a float
# getint() and getboolean() also do this for their respective types
server = ([login to view URL]('server', 'host'), [login to view URL]('server', 'port'))
username = [login to view URL]('login', 'username')
password = [login to view URL]('login', 'password')
log("Config OK...")
while True:
try:
[login to view URL](reconnect_interval)
log("reconnecting...")
sock = [login to view URL](socket.AF_INET, socket.SOCK_STREAM)
[login to view URL](server)
[login to view URL]([login to view URL]("I", 1))
assert([login to view URL](4) == [login to view URL]("I", [login to view URL]))
[login to view URL]([login to view URL]("32s32s", username, password))
assert([login to view URL](4) == [login to view URL]("I", [login to view URL]))
[login to view URL]([login to view URL]("I", 1))
assert([login to view URL](4) == [login to view URL]("I", [login to view URL]))
log("Connected to server")
while True:
msg = ""
(r, w, e) = [login to view URL]([sock], [], [sock], echo_timeout)
if not r:
raise Exception("Connection was closed by peer")
msg = [login to view URL](4)
if msg == [login to view URL]("I", [login to view URL]):
[login to view URL](msg)
else:
(port,) = [login to view URL]("I", msg)
print "port: %d" % port
sockets = [0, 0]
acceptors = [False, False]
try:
sockets[0] = [login to view URL](socket.AF_INET, socket.SOCK_STREAM)
sockets[0].connect((localhost, port))
except Exception:
print "Problem"
[login to view URL]([login to view URL]("I", [login to view URL]))
continue
[login to view URL]([login to view URL]("I", [login to view URL]))
(sport,) = [login to view URL]("I", [login to view URL](4))
print "SPort:%d" % sport
sockets[1] = [login to view URL](socket.AF_INET, socket.SOCK_STREAM)
sockets[1].connect((server[0], sport))
tunneler = Tunneler(sockets, acceptors)
except Exception as e:
log(str(e))
try:
[login to view URL](socket.SHUT_RDWR)
except Exception:
pass
while True:
try:
start()
except Exception as e:
log(str(e))
------------------