[PyQt] socket problem
Prashant Saxena
animator333 at yahoo.com
Thu Dec 3 09:19:38 GMT 2009
Here are the two version of my Receiver & Sender scripts:
Receiver
if status:
# Create socket
self.socket = QtNetwork.QUdpSocket(self)
self.socket.setReadBufferSize(buffer)
self.socket.bind(QHostAddress.LocalHost, port, QtNetwork.QUdpSocket.ShareAddress)
self.socket.readyRead.connect(self.dataArrived)
msg=("Socket opened at host=%s, port=%d." % (host, port))
# Stop Communication.
else:
# Close socket
self.socket.disconnectFromHost()
self.socket.waitForDisconnected()
self.socket.close()
msg=("Socket closed at host=%s, port=%d." % (host, port))
Sender:
import socket
# Set the socket parameters
host = "localhost"
port = 6268
addr = (host, port)
service = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
data = "This is a test string."
try:
service.connect(addr)
service.send(data)
except Exception, (value, message):
if service:
service.close()
print message
service.close()It seems Receiver script is not opening the port for listening.
Thanks in advance
Prashant
PyQt 4.6.1
Python 2.6.2
Win XP 32
The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
More information about the PyQt
mailing list