Return to Snippet

Revision: 456
at July 14, 2006 08:15 by buscarini


Updated Code
import socket
import sys

host = ''
port = 50000
backlog = 5
size = 1024
s = None
try:
	s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
	s.bind((host,port))
	s.listen(backlog)
except socket.error,(value,message):
	if s:
		s.close()
	print "Could not open socket: " + message
	sys.exit(1)
while 1:
	client,address = s.accept()
	data = client.recv(size)
	if data:
		print(data)
		client.send(data)
		if (data=="quit"):
			sys.exit(0)
	client.close()

Revision: 455
at July 14, 2006 08:08 by buscarini


Updated Code
import socket


host = ''
port = 50000
backlog = 5
size = 1024
s = None
try
	s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
	s.bind((host,port))
	s.listen(backlog)
except socket.error,(value,message):
	if s:
		s.close()
	print "Could not open socket: " + message
	sys.exit(1)
while 1:
	client,address = s.accept()
	data = client.recv(size)
	if data:
		client.send(data)
	client.close()

Revision: 454
at July 14, 2006 08:03 by buscarini


Updated Code
import socket


host = ''
port = 50000
backlog = 5
size = 1024

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((host,port))
s.listen(backlog)
while 1:
	client,address = s.accept()
	data = client.recv(size)
	if data:
		client.send(data)
	client.close()

Revision: 453
at July 14, 2006 08:00 by buscarini


Initial Code
import socket


host = ''
port = 50000
backlog = 5
size = 1024

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((host,port))
s.listen((host,port))
while 1:
	client,address = s.accept()
	data = client.recv(size)
	if data:
		client.send(data)
	client.close()

Initial URL

                                

Initial Description

                                

Initial Title
Servidor de echo

Initial Tags

                                

Initial Language
Python