[Tutor] Network Programming Information and terminology
byron at christianfreebies.com
Mon Aug 22 06:37:27 CEST 2005
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.
# PYTHON SERVER
# Create connection.
mySocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Get data coming in from client.
data, client = mySocket.recvfrom(100)
print 'We have received a datagram from', client, '.'
# Send a response to confirm reception!
mySocket.sendto ( 'Message confirmed: ' + data, client )
# Client program
from socket import *
# Set the socket parameters
host = "127.0.0.1"
port = 2727
buf = 1024
addr = (host,port)
# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)
def_msg = "===Enter message to send to server===";
print "\n", def_msg
# Send messages
data = raw_input('>> ')
if not data:
print "Sending message '",data,"'....."
# Receive the response back from the server.
data, client = UDPSock.recvfrom(100)
# 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