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

Substitute regex match groups where match groups may overlap
How to print out the first and last 1000 lines using beautiful soup
Call Grandparent Method without executing parent method through Mixin
Python/Pandas find closest value above/below in one Column
Pandas: set a default datetime for None values
NLTK can't find the Stanford POS tagger model file
Python __get__ differences between static instance and member
Splitting a 1-d numpy array from tdms file, and plot shorter time series/intervalls from the original array
Why there are more python processes than the number of cores in Spark?
Filling in a completely empty list of lists in an arbitrary order
How to create random orthonormal matrix in python numpy
Fill an image with pre-defined pattern with Wand
How to use a post_save receiver with django-polymorphic?
giving a name to a pandas dataframe?
mistake comparing datetime, python
numpy testing assert array NOT equal

Categories

HOME
arrays
xbox-live
sass
payment-gateway
tinyos
raspbian
parse-server
h2
appmaker
recyclerview
tizen-wearable-sdk
jframe
shader
currency
height
keystore
spinnaker
finite-group-theory
symfony-forms
glpk
backpropagation
rworldmap
bootstrap-typeahead
tampermonkey
non-deterministic
python-textprocessing
sumo
opencart2.3
upnp
forum
vertex-buffer
autofill
outsystems
pdflatex
google-drive-realtime-api
npm-shrinkwrap
modulo
remote-server
shibboleth
autocompletetextview
declare
android-preferences
ddms
dojox.grid.datagrid
number-theory
mouseclick-event
windows-95
slidesjs
cdk
objloader
windows-azure-pack
picasa
sonarqube5.3
site-prism
anti-patterns
debian-based
lines-of-code
shift-jis
jazz
jython-2.7
ejabberd-saas
obfuscar
cloudpebble
scala-2.11
em
funq
sthttprequest
power-law
spdy
phpdocx
kraken.js
bounds
operations
circos
healthvault
nimrod
ftp4j
sharpmap
process-monitor
xml-libxml
tridion2009
returnurl
getusermedia
hibernate3
objective-c-protocol
maven-ant-tasks
out-of-browser
chatroom
j-interop
swfloader
standardized

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