msg_gen integration, port closing and testing fix

rename send_rpc to msg_gen
improvement for msg_gen return value
new state for xmlrpc handler