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'
Ïà¹ØÎĵµ£º
À´×Ôbccn CÓïÑÔÂÛ̳
Ê×ÏÈÉùÃ÷Ò»µã£¬±¾ÎÄΪתÌù¡£
dz̸CÖеÄmallocºÍfree
×÷Õߣºlj_860603 ÔĶÁÈ˴Σº43013 ÎÄÕÂÀ´Ô´£º±¾Õ¾Ô´´ ·¢²¼Ê±¼ä£º2006-8-5 ÍøÓÑÆÀÂÛ(32)Ìõ
ÔÌû¼°ÌÖÂÛ£ºhttp://bbs.bccn.net/thread-82212-1-1.html
ÔÚCÓïÑÔµÄѧϰÖУ¬¶ÔÄÚ ......
ÏȽ«ÉÏÃæ´´½¨ºÃµÄtestdemo¹¤³ÌĿ¼\£¬½«C:\Python25\Lib\site-packages\django\binÖеÄtestdemoĿ¼¿½±´µ½×Ô¼ºµÄ¹¤×÷Ŀ¼ÖУ¬È»ºóÆô¶¯eclipse£¬µã»÷“File”->“New”->“project…”£¬½«»á¿´µ½ÒÔÏ»Ãæ
Ñ¡Ôñ“Pydev Project”£¬µã»÷“Next&rdquo ......
ÒÔÏÂΪÎÒÔÚ´¦ÀíÍøÒ³±àÂëÎÊÌâ¿´µÄÎÄÕ£¬ÏÖÔÚдÅÀ³æ×Ô¼º´¦ÀíÍøÒ³±àÂëÎÊÌâȷʵ±È½ÏÂé·³£¬ÍøҳҲûÓй涨
Ò»¶¨ÒªÔÚMETAÍ·ÐÅÏ¢Àï´ø±àÂëÐÅÏ¢£¬¶øºÜ¶àÈËдµÄ̽²â±àÂë¾ÍÊÇ»ñÈ¡META£¬ÕâÊDz»¿ÉÈ¡µÄ£¬¶øÓеÄÈËÔòÊÇ·ÖÎöHTTP·µ»ØµÄÊý¾Ý°üÀï±ßµÄ
charset£¬È磨a.headers.getparam('charset')£©£¬¶øHTTP°üûÓй涨һ¶¨Òª´øcharset£¬ËùÒ ......
http://blog.alexa-pro.cn/?p=197
1.´ò¿ªÎļþ´úÂëÈçÏ£º
>>> f = open(”d:test.txt”, “w”)
˵Ã÷£ºµÚÒ»¸ö²ÎÊýÊÇÎļþÃû³Æ£¬°üÀ¨Â·¾¶£»µÚ¶þ¸ö²ÎÊýÊÇ´ò¿ªµÄģʽmode’r'£ºÖ»¶Á£¨È±Ê¡¡£Èç¹ûÎļþ²»´æÔÚ£¬ÔòÅ׳ö´íÎ󣩒w'£ºÖ»Ð´£¨Èç¹ûÎļþ ²»´æÔÚ£¬Ôò×Ô¶¯´´½¨Îļþ£©’a'£º¸½¼ ......
extern "C"
extern "C"°üº¬Ë«Öغ¬Ò壬ÆäÒ»£º±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä¶þ£º±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£
1£©±»extern “C”ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ ......