Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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'


Ïà¹ØÎĵµ£º

CÖеÄϸ½Ú£¬ÎÒȷʵ²»ÖªµÀ

ÏÂÃæ˵µ½µÄCÓïÑÔÖеÄ֪ʶ£¬ÎÒÖ»ÊÇÔÚ¹¤×÷Öо­³£¼ûµ½»òÓõ½£¬µ«´ÓδÉΪʲô£¬½ñÌì²ÅÈ´µÀÔ­À´¼ò¼òµ¥µ¥ÏÂÃæÔÐÓýÕâÎÞÇîµÄ֪ʶµãºÍÎÒµÄäµã£¬ÊǸñßѧϰ±ß¼Ç¼ÁË¡£
Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1 . ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
         #define ......

Eclipse»ùÓÚpython¡¢Django×öWeb¿ª·¢

 ÏȽ«ÉÏÃæ´´½¨ºÃµÄtestdemo¹¤³ÌĿ¼\£¬½«C:\Python25\Lib\site-packages\django\binÖеÄtestdemoĿ¼¿½±´µ½×Ô¼ºµÄ¹¤×÷Ŀ¼ÖУ¬È»ºóÆô¶¯eclipse£¬µã»÷“File”->“New”->“project…”£¬½«»á¿´µ½ÒÔÏ»­Ãæ
 
Ñ¡Ôñ“Pydev Project”£¬µã»÷“Next&rdquo ......

PythonÎļþ²Ù×÷ ´ò¿ª,¶ÁÈ¡,¹Ø±Õ

http://blog.alexa-pro.cn/?p=197
1.´ò¿ªÎļþ´úÂëÈçÏ£º
>>> f = open(”d:test.txt”, “w”)
˵Ã÷£ºµÚÒ»¸ö²ÎÊýÊÇÎļþÃû³Æ£¬°üÀ¨Â·¾¶£»µÚ¶þ¸ö²ÎÊýÊÇ´ò¿ªµÄģʽmode’r'£ºÖ»¶Á£¨È±Ê¡¡£Èç¹ûÎļþ²»´æÔÚ£¬ÔòÅ׳ö´íÎ󣩒w'£ºÖ»Ð´£¨Èç¹ûÎļþ ²»´æÔÚ£¬Ôò×Ô¶¯´´½¨Îļþ£©’a'£º¸½¼ ......

extern "C"

extern "C"
extern "C"°üº¬Ë«Öغ¬Ò壬ÆäÒ»£º±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä¶þ£º±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£
1£©±»extern “C”ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
    externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ