TCP Python Socket Server Response -


i'm writing tcp python script act server , retrieve temperature reading machine (the client). need pass command client server , listen output of response. reach cmd definition line, when s.accept() called i'm left hanging no response client.

server.py

import socket port = 7777 ip = raw_input('192.168.62.233')  s = socket.socket(socket.af_inet, socket.sock_stream) s.bind((ip, port)) s.listen(1) print "waiting on port: ", port  while true:     cmd = raw_input('krdg? a[term]')#command send client      conn, addr = s.accept()      s.send(cmd)      print "it sent"      data = conn.recv(4096)      print "received:", data, " address ", addr 

edit:

i believe you're correct, should consider code client , temperature readout @ server. left hanging after "here 2" when go s.recv().

client.py

import socket  ip = '192.168.62.233' port = 7777              # same port used server s = socket.socket(socket.af_inet, socket.sock_stream) s.connect((ip, port))  print 'here' s.send('krdg? a[term]')  print 'here 2' data = s.recv(4096) print 'here 3' s.close() print 'received', repr(data) 

usually, tcp server accept block while waits client connect. have checked make sure client can , connecting? use tool tcpdump or similar watch network activity , make sure client connecting.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -