En cours

c/c++ comunication componet

i have a component 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 = [url removed, login to view]([url removed, login to view]([url removed, login to view]), '[url removed, login to view]')

config = [url removed, login to view]()

[url removed, login to view](path)

# getfloat() raises an exception if the value is not a float

# getint() and getboolean() also do this for their respective types

server = ([url removed, login to view]('server', 'host'), [url removed, login to view]('server', 'port'))

username = [url removed, login to view]('login', 'username')

password = [url removed, login to view]('login', 'password')

log("Config OK...")

while True:

try:

[url removed, login to view](reconnect_interval)

log("reconnecting...")

sock = [url removed, login to view](socket.AF_INET, socket.SOCK_STREAM)

[url removed, login to view](server)

[url removed, login to view]([url removed, login to view]("I", 1))

assert([url removed, login to view](4) == [url removed, login to view]("I", [url removed, login to view]))

[url removed, login to view]([url removed, login to view]("32s32s", username, password))

assert([url removed, login to view](4) == [url removed, login to view]("I", [url removed, login to view]))

[url removed, login to view]([url removed, login to view]("I", 1))

assert([url removed, login to view](4) == [url removed, login to view]("I", [url removed, login to view]))

log("Connected to server")

while True:

msg = ""

(r, w, e) = [url removed, login to view]([sock], [], [sock], echo_timeout)

if not r:

raise Exception("Connection was closed by peer")

msg = [url removed, login to view](4)

if msg == [url removed, login to view]("I", [url removed, login to view]):

[url removed, login to view](msg)

else:

(port,) = [url removed, login to view]("I", msg)

print "port: %d" % port

sockets = [0, 0]

acceptors = [False, False]

try:

sockets[0] = [url removed, login to view](socket.AF_INET, socket.SOCK_STREAM)

sockets[0].connect((localhost, port))

except Exception:

print "Problem"

[url removed, login to view]([url removed, login to view]("I", [url removed, login to view]))

continue

[url removed, login to view]([url removed, login to view]("I", [url removed, login to view]))

(sport,) = [url removed, login to view]("I", [url removed, login to view](4))

print "SPort:%d" % sport

sockets[1] = [url removed, login to view](socket.AF_INET, socket.SOCK_STREAM)

sockets[1].connect((server[0], sport))

tunneler = Tunneler(sockets, acceptors)

except Exception as e:

log(str(e))

try:

[url removed, login to view](socket.SHUT_RDWR)

except Exception:

pass

while True:

try:

start()

except Exception as e:

log(str(e))

Compétences : Programmation C, PHP, Architecture Logicielle

Voir plus : struct programming, socket programming python, socket login, sleep programming, python socket programming, programming types, print pack, peer programming, float programming, else programming, programming else, programming get, programming continue, sys, str, socket server, sleep, python c, programming r, port, float, c w, c r, socket programming server, php connection select

Concernant l'employeur :
( 39 commentaires ) HAIFA, Israel

N° du projet : #1059504

Décerné à :

jasminjx

Hi. I have a great experience about c, c++, python and networking. If you choose me, i will do it quickly and smartly. Regards.

50 $ USD en 1 jour
(4 Commentaires)
3.7

2 freelance ont fait une offre moyenne de 115 $ pour ce travail

srinichal

let me know what needs to be done

180 $ USD en 5 jours
(144 Commentaires)
7.3