Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
shoutclient.py
Package: MMOPRG_server_dev.rar [view]
Upload User: ghyvgy
Upload Date: 2009-05-26
Package Size: 547k
Code Size: 1k
Category:
Other Games
Development Platform:
Python
- from twisted.internet.protocol import Protocol, ClientFactory
- class Shout(Protocol): # Class designed to manage a connection.
- stringToShout = "Twisted is great!" # a string to send the echo server
- def connectionMade(self): # Method called when connection established.
- self.buf = "" # create an empty buffer
- print "Shouting:", repr(self.stringToShout)
- self.transport.write(self.stringToShout)
- def dataReceived(self, data): # Method called when data is received.
- self.buf += data # buffer any received data
- if self.buf == self.stringToShout: # if we've received the full message
- self.transport.loseConnection() # then close the connection.
- print "Echoed:", repr(self.stringToShout)
- reactor.stop()
- class ShoutClientFactory(ClientFactory):
- def buildProtocol(self, address):
- return Shout() # Build Protocols on incoming connections
- from twisted.internet import reactor
- # connect to local port 1234 and expect an echo.
- reactor.connectTCP("localhost", 1234, ShoutClientFactory())
- reactor.run() # run the main loop until the user interrupts it