added socket and sys.argv processing