[Pythonmac-SIG] problem with socket library in 2.0?
James B. Wilkinson
jimmy@CS.cofc.EDU
Tue, 30 Jan 2001 21:48:10 -0500
Last year I wrote a rudimentary client/server pair using
dgramsockets. I used it in my networking class as a demo. Today I
installed Macpython 2.0 on my Mac, and that seems to have broken the
server. Things just hang as if the packet from the client is not
being delivered. If I drag the server onto the 1.5.2 interpreter, it
still works fine with the same client.
Can anybody else confirm this?
Thanks
#Datagram server
from socket import *
import struct
HOST = '127.0.0.1'
PORT = 50007
def serve():
s = socket(AF_INET, SOCK_DGRAM)
s.bind((HOST, PORT))
test(s)
s.close()
def test(s):
data, addr = s.recvfrom(1024)
print 'Connected by', addr, "got: ", data
s.sendto(data, addr)
if __name__ == '__main__':
serve()
#Datagram client
from socket import *
HOST = 'burton.cs.cofc.edu'
PORT = 50007
s = socket(AF_INET, SOCK_DGRAM)
s.sendto('Hello, world.', (HOST, PORT))
data, addr = s.recvfrom(1024)
s.close()
print 'Received:', `data`, 'from', addr
--
-------------------------------------------------------------
Jimmy Wilkinson | Perfesser of Computer Science
jimmy@cs.CofC.edu | The College of Charleston
(843) 953-8160 | Charleston SC 29424
If there is one word to describe me,
that word would have to be "profectionist".
Any form of incompitence is an athema to me.