Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python udp c/s ¼Ç¼

server:
import sys
import socket
host = sys.argv[1]
port = int(sys.argv[2])
 
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
 
s.bind((host,port))
 
while 1:
    try:
        message, address = s.recvfrom(100)
        print "Got data from", address, message
 
        #cs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        #cs.sendto(message, address)
        #cs.close()
 
        s.sendto(message, address)
 
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        traceback.print_exc()
client:
import socket
import sys
import time
count = 0
while (count < 9):
    try:
        time.sleep(1)
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.sendto("test", ("192.168.22.209", 1234))
        data,addr = s.recvfrom(1024)
        if data:
            print 'received:',data,'from',addr
        s.close()
    except:
        print 'except'


Ïà¹ØÎĵµ£º

s3c2410 RTCÇý¶¯¿ò¼ÜlinuxÄÚºËÔ´Âë·ÖÎö

ʵÔÚÎÞÁÄÖоͽ«Ô­À´µÄһЩ¶«Î÷ÕûÀíÁËһϣ¬×Ô¼ºÊǸö¼ÇÐÔ²»ºÃµÄÈË£¬¸ô¶Ïʱ¼äÕûÀí×Ô¼º£¬Í¬Ê±Ò²Ï£Íû¿ÉÒÔ·½±ãËûÈË¡£
----------------------------------------------------------------------------------------------------------------------------------------
/**//*************************************************** ......

LinuxÏÂCÓïÑÔʵÏÖ×Ö·û´®×Ó´®Ìæ»»


    ÓÉÓÚLINUX
CûÓжÔ×Ö·û´®×Ó´®Ìæ»»¹¦ÄÜ,ËùÒÔÎÒ×Ô¼ºÐ´ÁËÒ»¸östr_replaceº¯Êý,ʵÏÖÁË×Ö·û´®Ìæ»».
Çë´ó¼Ò²Î¿¼.
/*
 * FUNCTION     : str_replace
 *
ABSTRACT     : replace child string in a string.
 *
PARAMETER  &nbs ......

ÔÚpythonÖд¦ÀíXML×ܽá

±¾ÎÄ×ܽáÁËÔÚPythonÖÐÖ÷ÒªµÄ¼¸ÖÖ´¦ÀíXMLµÄ·½·¨£º
Element Tree
SAX
Dom
ʹÓõÚÈý·½Àà¿âÈçAmara 2.x£¬ libxml2dom µÈ
Element Tree
Element TreeÊÇPython 2.5ÒýÈëµÄʹÓüòµ¥£¬¿ì½ÝµÄ´¦Àí·½·¨£¬ Ò²ÊÇPython±ê×¼Àà¿âÍƼöµÄ´¦ÀíXMLµÄ·½·¨¡£
ËüʹÓÃÊ÷ÐνڵãµÄÐÎʽÀ´¶ÁдXML¡£Element TreeÊÇÇáÁ¿¼¶µÄDOM£¬ ËùÒÔÊ ......

PythonÖо²Ì¬·½·¨µÄʵÏÖ

×÷ÕߣºÀÏÍõ
PythonËƺõºÜÌÖÑáÐÞÊηû£¬Ã»Óг£¼ûµÄstaticÓï·¨¡£Æ侲̬·½·¨µÄʵÏÖ´óÖÂÓÐÒÔÏÂÁ½ÖÖ·½·¨£º
µÚÒ»ÖÖ·½Ê½£¨staticmethod£©£º
>>> class Foo:
        str = "I'm a static method."
        def ba ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ