Tag Archives: hello world

Python – Hello World Client

0
Filed under python
Tagged as , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple client which initiate connection on port 3000 at localhost. Tested on Linux.
Usage: You need helloworld-server to process helloworld-client request

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

import socket 

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 3000))
print s.recv(1024) # up to 1024 bytes



python,logo,banner

Python – Hello World Server

0
Filed under python
Tagged as , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple server which listen on port 3000 at localhost. Tested on Linux.
Usage: You need helloworld-client to initiate connection and get response from hello world server.

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

import socket 

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("127.0.0.1", 3000))
s.listen(1) # max connection = 1
q,v = s.accept()
q.send("Hello World from Python Server")



python,logo,banner