Return to Snippet

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


Updated Code
import socket
import sys

host = 'localhost'
port = 50000
size = 1024
s = None

if (len(sys.argv)>0):
	message = sys.argv[1]
else:
	message = "Hello, World!"

try:
	s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
	s.connect((host,port))
except socket.error,(value,errmessage):
	if s:
		s.close()
	print "Could not open socket: " + errmessage
	sys.exit(1)
s.send(message)	
data = s.recv(size)
s.close()
print 'Received: ',data

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


Updated Code
import socket

host = 'localhost'
port = 50000
size = 1024
s = None
try:
	s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
	s.connect((host,port))
except socket.error,(value,message):
	if s:
		s.close()
	print "Could not open socket: " + message
	sys.exit(1)
s.send('Hello,World')	
data = s.recv(size)
s.close()
print 'Received: ',data

Revision: 459
at July 14, 2006 08:05 by buscarini


Initial Code
import socket

host = 'localhost'
port = 50000
size = 1024
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((host,port))
s.send('Hello,World')
data = s.recv(size)
s.close()
print 'Received: ',data

Initial URL

                                

Initial Description

                                

Initial Title
Cliente de echo

Initial Tags

                                

Initial Language
Python