Newbie Question: Sockets

Kevin Bass kbass1 at nc.rr.com
Tue Nov 5 17:53:58 EST 2002


I am attempting to process data within a socket. The socket establishes communications on both servers but the data does not come out the way that I want it. How do I store the retrieved data into an array or another value? If there are multiple values, how can I store this information? Thanks!


client.py
=======
import sys
from socket import *

HOST = '127.0.0.1'
PORT = 8080

var_name = 'Mousey Moo'

sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.connect((HOST, PORT))

for line in message:
   sockobj.send(var_name)
   data = sockobj.recv(1024)
   print 'Client Received', 'data'
sockobj.close()



Server.py
========
from socket import *

HOST ='127.0.0.1'
PORT = 8080
date=""

sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.bind((HOST, PORT))
sockobj.listen(5)

while 1:
  conn, addr = sockobj.accept()
  print 'Server Connected by', addr
  data = conn.recv(1024)
  print 'The received data is ', data
  print 'Closing conn'
  conn.close()
print 'Shutting down'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20021105/1d57d965/attachment.html>


More information about the Python-list mailing list