python


how to send response from server to client using python socket?


i want to communication between two system using python socket, in which one machine is local system(client) and another is public system(server),
the code i write is :
client.py
import socket
import commands
import sys
import time
s = socket.socket()
state = sys.argv[1]
pname = sys.argv[2]
user = commands.getoutput("whoami")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('132.65.45.156', 5001))
info = commands.getoutput("echo '%s','%s','%s','%s'"%(state,ip,user,pname))
while True:
data2 = info
s.sendall(data2)
break
server.py
import socket
import time
import string
import sys
import base64
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 5001))
sock.listen(5)
while True:
newSocket, address = sock.accept()
print "Connected from ", address
filename = newSocket.recv(5001)
while True:
data = newSocket.recv(5001)
if not data: break
print filename, "Received\n"
sock.close()
After getting response from client to server, what to do if server want to send response to client ?

Related Links

Django creating relation
Pairwise appending in python without ZIP [duplicate]
Python: Creating many instances of a class
Python Social Auth, Extending Disconnect Pipeline
Forward Euler N-Body Simulation in Python not returning correct results
OSError errno 13 Permission Denied Python CGI os.listdir
python encode the defined variable from txt file
Tkinter runtime error maximum recursion when open a window
Find out Python version from source code (or Heroku)
Recursive Function named Power
415 error when uploading to API
How to interfacing
Collision detection with PyGame
Why is Python not setting up my cron job's time properly?[Solved]
Training Data Set in NLTK Python
Pip3 packages can't be found/used by the terminal

Categories

HOME
d
otrs
playframework
windows-store-apps
couchdb-2.0
apache2
appmaker
jpanel
browserify
docker-windows
internet-explorer-11
actionscript-2
slim-3
google-plus
x11
iso
nixos
cortex-a
cpanel
maxima
simple-injector
equalizer
multiple-monitors
mod-pagespeed
reduction
rhapsody
prestodb
multicore
sonarqube-msbuild-runner
k2
novnc
yosys
jflex
excel-2013
edge-detection
thinking-sphinx
helix-3d-toolkit
backup-strategies
pyscripter
m2e
idl
division
transient
gettext
superpowered
wfp
vsts-package-management
npm-publish
image-compression
magiczoomplus
fax
bing-translator-api
spring-bean
uiviewpropertyanimator
ti-basic
instruction-set
in-memory-database
opencpu
autoresize
spyne
cjson
iostat
cfeclipse
software-product-lines
multiple-file-upload
spring-lemon
drf-nested-routers
function-fitting
coldfusion-7
document-oriented-db
achartengine
ytplayerview
git-checkout
epl
symfony-2.6
system.web
adaptive-compression
code-testing
smartystreets
colt
wss
delphi-xe3
chrome-for-android
wic
image-zoom
justgage
appfog
magickwand
domain-calculus
attachevent
git-filter-branch
datarepeater
unions
getstring
hibernate3
gjs
concurrent-programming
fileutils
selectmanycheckbox
goliath
clause
google-instant
oggvorbis

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App