Package: kangaroo-sockets
Kangaroo Sockets 🦘Kangaroo is a user-friendly lib for sockets in Python. You can send and listen to TCP sockets with a few lines of code.ContentsInstallationQuick startDocumentationExamplesDevelopmentTestingContributingLicenseInstallationFirst you needPythoninstalled (version 3.6+ is required), then you can install Kangaroo:$pipinstallKangarooImport it ib your code:importKangaroo(Optional) installJaguarfor testing the sockets:$brewtapleozz37/jaguar

$brewinstalljaguarQuick startSample code for sending and listening to a port:fromsrc.kangarooimportKangarooimportthreadingimporttimedeflisten_port(port:int):r=Kangaroo().listen(port)whileTrue:ifr.has_new_message():print(r.get_message())if__name__=='__main__':x=threading.Thread(target=listen_port,args=(3000,))y=threading.Thread(target=listen_port,args=(3001,))x.start()y.start()whileTrue:Kangaroo().send(3000,"Hello")Kangaroo().send(3001,"World")time.sleep(1)DocumentationThe library consists on two features: listen and send to a given port. You can check the full documentation on pypi.ListenReceives aportasintand returns a Kangaroo instance.deflisten(self,port:int):Usage example:kangaroo=Kangaroo()r=kangaroo.listen(3000)l=kangaroo.listen(3001)SendReceives aportand amessage, both asstring.defsend(self,port:int,message:str)->None:Usage example:kangaroo=Kangaroo()r=kangaroo.listen(3000)kangaroo.send(3000,"Hello, World!")Messageshas_new_messages()returns aboolif there's a new message:defhas_new_message(self)->bool:get_message()returns the last message asstr:defget_message(self)->str:Usage example:importKangarooif__name__=='__main__':kangaroo=Kangaroo()r=kangaroo.listen(3000)kangaroo.send(3000,"Hello world")ifr.has_new_message():print(r.get_message())DevelopmentThis project usespipenvandpre-commitin order to run some static
checks and formatting on the code. After clone the repository you need to create
a newvirtual environmentand install the dependencies:$pipenvshell

$pipenvinstall--dev--skip-lock

$pre-commitinstallEvery time you run thegit commitcommand the code will be checked. To
run the checking manually, run:$pre-commitrun--all-filesTestingThe tests uses the pytest framework. To run the test suit with coverage you can do the following:$pytest--cov=.-v============================================================================================================================testsessionstarts============================================================================================================================platformdarwin--Python3.8.2,pytest-6.1.2,py-1.9.0,pluggy-0.13.1--/Library/Developer/CommandLineTools/usr/bin/python3
cachedir:.pytest_cache
rootdir:/Users/leo/Documents/codes/kangaroo
plugins:cov-2.10.1
collected4items

tests/kangaroo_test.py::test_send_with_successPASSED[25%]tests/kangaroo_test.py::test_listen_with_successPASSED[50%]tests/kangaroo_test.py::test_get_message_failsPASSED[75%]tests/kangaroo_test.py::test_has_new_message_failsPASSED[100%]----------coverage:platformdarwin,python3.8.2-final-0-----------
NameStmtsMissCover
--------------------------------------------
__init__.py30100%
setup.py440%
src/__init__.py00100%
src/kangaroo.py310100%
tests/__init__.py00100%
tests/kangaroo_test.py230100%
--------------------------------------------
TOTAL61493%ContributingA full guideline about contributing to Kangaroo can be found in theCONTRIBUTING.mdfile.LicenseHare is released under theMIT License.