sockets
Bas van Gils
bas.vangils at home.nl
Thu Jan 3 05:44:09 EST 2002
Hi
I am building a `proof of concept' for my final thesis. This involves
some socket-programming. I was new to this subject so I read some man
pages and the relevant chapters from "Programming Python" (2nd edition).
Here's what I came up with (in interactive mode):
>>> from socket import *
>>> sockobj = socket(AF_INET,SOCK_STREAM)
>>> sockobj.connect( ("kubsuw.kub.nl",7124) )
>>> sockobj.recv(1024)
'Welcome to the Tagdemo server.\n'
>>> sockobj.send("Dit is een test .\n")
18
>>> data = sockobj.recv(1024)
>>> print data
Dit//NNP is/VBZ een//RB test/VB ./.
Since this worked fine I moved it to a script:
from socket import *
sockobj = socket(AF_INET,SOCK_STREAM)
sockobj.connect( ("kubsuw.kub.nl",7124) )
# the server sends a welcome-mesg
sockobj.recv(1024)
# send a test-line to the tagger
# receive the data and print it
sockobj.send("Dit is een test .\\n")
data = sockobj.recv(4096)
print data
# close the socket
sockobj.close()
print "end"
However, that didn't word:
bas at kubstu2:~$ python c2.py
Welcome to the Tagdemo server.
Dit
end
I found this rather odd.... I asked around with my collegues but they
couldn't help out. Anyone on the list have a suggestion?
many thanx in advance
Bas
--
Bas van Gils <bas.vangils at home.nl> - http://members.home.nl/bas.vangils
Build a system that even a fool can use, and only a fool will want to use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020103/88768d6d/attachment.sig>
More information about the Python-list
mailing list