Help! string from buffer to socket

cat3 cat_stack at erraticimpact.zzn.com
Tue Dec 4 19:30:48 EST 2001


I'm trying to write a class that allows arbitrary strings to be added
to the data to be sent on a socket.  A certain amount of data will be
collected from the buffer when the socket is ready for sending.  I
don't have lots of network or OOP experience, but am trying to get a
simple class together that can do this.  I'm stuck on my read and feed
methods.  Can someone give me a fresh pair of eyes and maybe a little
wisdom?  Thanks!

Here's what I have so far:

class DataFifo:
import socket

# constructor
	def __init__(self):
		# initialize properties
		arbSTRING = string(raw_input("Enter a string: " ))
		
	def feed(self, feed):
		self.feed = (arbSTRING)
#should I turn the string into a list and read four elements of the
list at a #time?  Use string.split(string, '.')?
	
	def read(self, read):
	        #read = list[0:3]  ????
		self.read = read 
	
	def send_fifo(self, send_fifo):
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	    s.connect("www.teleias.com", 80)
		s.listen(1)
		conn, addr = s.accept()
		print 'Connected by', addr
	while 1:
		data = conn.recv(1024)
		if not data: break
		conn.send(arbSTRING)  #data to be sent
		conn.close()



More information about the Python-list mailing list