[Tutor] Network Programming Information and terminology

Byron byron at christianfreebies.com
Mon Aug 22 06:37:27 CEST 2005

Hi John,

Here is a link that you might find useful:


Listed below are two very basic Python IM programs.  You'll need to run 
the server first -- let it run in the background.  Once this is running, 
start the second program, which allows you to type in a message and then 
the server program will acknowledge the reception of the data and then 
send a message back to you.



import socket

# Create connection.
mySocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
mySocket.bind(('', 2727))

while True:
	# Get data coming in from client.
	data, client = mySocket.recvfrom(100)
	print 'We have received a datagram from', client, '.'
	print data
	# Send a response to confirm reception!
	mySocket.sendto ( 'Message confirmed: ' + data, client )


# Client program

from socket import *

# Set the socket parameters
host = ""
port = 2727
buf = 1024
addr = (host,port)

# Create socket

def_msg = "===Enter message to send to server===";
print "\n", def_msg

# Send messages
while (1):
	data = raw_input('>> ')
	if not data:
			print "Sending message '",data,"'....."
	# Receive the response back from the server.
	data, client = UDPSock.recvfrom(100)
	print data

# Close socket


Hope this helps,



John Walton wrote:

>Hello. It's me again.  Thanks for all the help with
>the Python Networking Resources, but does anyone know
>what I'll need to know to write a paper on Network
>Programming and Python.  Like terminology and all
>that.  Maybe I'll have a section on socketets, TCP,
>Clients (half of the stuff I don't even know what it
>means).  So, does anyone know any good websites with
>Network Programming information.  Thanks!
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list