Esempio n. 1
0
def connectASclient():

	message= "this is a fuking testmessage"

	client = socket_io()
	status = client.socket_open(target, port, False)
	if not status:
	  print "* Fail open socket *"
	  end()

	status = client.socket_write(message)
	
	if not status:
	  print "* Fail send message*"
	  end()

	client.socket_close()
Esempio n. 2
0
def connectASserver():

	message = " "
	ip_sender = ' '

	server = socket_io()
	status = server.socket_open(target, port, True)
	if not status:
	  print "* Fail open socket *"
	  end()

	message, ip_sender, status = server.socket_read() 

	if not status:
	  print "* Error during reading *"
	  end()

	print "reading ", message, " from ", ip_sender

	server.socket_close()
Esempio n. 3
0
def main():

    # create socket object
    myclient = socket_io()

    # first read config files
    err_msg, status = read_config_files()
    if not status:
        sys.exit(err_msg)

        # open socket as client
    status = myclient.socket_open(
        header.test_conf[header.str_server_ip], header.test_conf[header.str_server_port], False
    )
    if not status:
        sys.exit("Error to open socket as client")

        # show info for this modul
    print "-- this is the client test unit manager V 0.1 written in python 2 --"

    # show menue comments
    if header.test_conf[header.str_menue_on] == "True":
        for comment in header.menue_com:
            print comment

            # -----
            # the file menue
            # -----

            # request to the server read dir test files
    status = myclient.socket_write(header.c_file_rd)
    if not status:
        sys.exit("Error to send request")

    file_list, status = myclient.socket_read()
    if not status:
        sys.exit("Error to read file list")

    print file_list
Esempio n. 4
0
def main():
	
	cnt_timeout = 200 
	t_cnt = 0

	# the read data vom client
	data =""

	# create socket object
	myserver = socket_io()

	#first read config files
	err_msg, status = read_config_files()
	if not status:
	 sys.exit(err_msg)

	# define the key word filter for the communication
	filter= { (header.c_alive_q) : empty,
                  (header.c_alive_a) : empty,
                  (header.c_break)   : empty,
                  (header.c_next)    : empty,
		  (header.c_seq)     : empty,
		  (header.c_file_rd) : readDir}


	# show info	
	print "----"
	print "-- this is the server test unit manager V 0.1 written in python 2 --"
	print "waiting for client..."

        # open socket as server
        status= myserver.socket_open(header.test_conf[header.str_server_ip], header.test_conf[header.str_server_port], True)
        if not status:
         sys.exit("Error to open socket as server")
	else: print "connected"


	while 1:
	   
	   # read data from client
	   data, status = myserver.socket_read()
	   
	   # use the filter
	   try:
	     status = filter[data](myserver)
 	   except:
	     pass	    

	   # this is shit but if the client dead there come a 
	   # empty string back. there count them end bye.
	   # this is only a emergeny resolution
	   if data == "":
	    t_cnt = t_cnt + 1
	   else: t_cnt = 0   
	   	
	   if t_cnt == cnt_timeout:
	    end(myserver) 
	    sys.exit()





	print status