好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

socket python

socket python

python socket

 

?

from   socket import   *

HOST =   'localhost'

BUFSIZE =   1024

PORT =   21567

def   client_socket():

     ADDR =   (HOST, PORT)

     tcpclisock =   socket(AF_INET, SOCK_STREAM)

     tcpclisock.connect(ADDR)

 

     while   True :

         data =   raw_input ( '>' )

         if   not   data:

             break

         tcpclisock.send(data)

         data =   tcpclisock.recv(BUFSIZE)

         if   not   data:

             break

         print (data)

 

     tcpclisock.close()

if   __name__ = =   '__main__' :

     client_socket()

    

  

TCPserver端代码:

?

from   socket import   *

from   time import   ctime

import   threading

HOST =   ''

PORT =   21567

BUFSIZE =   1024

ADDR =   (HOST, PORT)

def   server(address, size):

     tcpSerSock =   socket(AF_INET, SOCK_STREAM)

     tcpSerSock.bind(address)

     tcpSerSock.listen( 5 )

 

     while   True :

         print ( "waiting for connecting!" )

         tcpcliSock, addr =   tcpSerSock.accept()

         print ( '...connect from:' , addr)

 

         while   True :

             data =   tcpcliSock.recv(size)

         if   not   data:

             break

             tcpcliSock.send( '[%s] %s'   %   (ctime(), data))

         tcpcliSock.close()

     tcpSerSock.close()

if   __name__ = =   '__main__' :

     threads =   []

     for   i in   range ( 5 ):

         ADDR =   (HOST, PORT +   i)

     t =   threading.Thread(target =   server, args =   (ADDR, BUFSIZE))

     threads.append(t)

     t.start()

 

      

  client端代码:

 

分类:  Originality

Originality

 

love 的Python 表示

摘要: """'17*x^2 - 16*|x|*y + 17*y^2 = 225'"""import numpy as npimport matplotlib.pyplot as pltX = np.arange(-5.0, 5.0, 0.1)Y = np.arange(-5.0, 5.0, 0.1)x, y = np.meshgrid(X, Y)f = 17 * x ** 2 - 16 * np.abs(x) * y + 17 * y ** 2 - 225fig = plt.figure()cs = plt.contour( 阅读全文

posted @  2012-07-09 20:15  1210150341 阅读(182) |  评论 (1)   编辑

 

python socket

摘要: from socket import *HOST = 'localhost'BUFSIZE = 1024PORT = 21567def client_socket(): ADDR = (HOST, PORT) tcpclisock = socket(AF_INET, SOCK_STREAM) tcpclisock.connect(ADDR) while True: data = raw_input('>') if not data: break tcpclisock.send(data) da... 阅读全文

posted @  2012-05-31 17:31  1210150341 阅读(13) |  评论 (0)   编辑

 

Github的入门简介

摘要: Git 在Windows下安装过程详情参见:http://help.github.com/win-set-up-git/首先需要注册注册网站:https://github.com/然后需要一个public key1、在~/.ssh目录下执行2、在本机住创建一个目录(algorithm)3、初始化 阅读全文

posted @  2012-05-19 19:25  1210150341 阅读(8) |  评论 (0)   编辑

作者: Leo_wl

    

出处: http://www.cnblogs.com/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于socket python的详细内容...

  阅读:35次