June 20th, 2004, 09:40 PM
I've read online both in ebooks and tutorials on how sockets work. All of which give a different example on how to get this set up. I've searched this forum as well, but can anyone provide an example of code that just sets up a socket and the client sends text and then ends the connects with the server socket.
June 20th, 2004, 10:39 PM
Quick example (no error checking):
Look here for more info: http://docs.python.org/lib/module-socket.html
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
June 20th, 2004, 11:13 PM
Can you maybe provide a server example as well ?
Thanks for the sample code as well, it's much appreciated.
June 21st, 2004, 09:01 AM
It shouldn't be too hard to expand on these to make them interactive if you so desire.
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
(client, addr) = server.accept()
print "Connection: ", addr
input = client.recv(1024)
print "Received: ", input
EDIT: There are some good protocol dependent and indepentent examples here: http://docs.python.org/lib/socket-example.html