All pastes #240808 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-11-05 22:13 UTC
rendered paste body
-*-coding:UTF-8-*-
# author : ismail danacı, onur yerlikaya

from socket import *

HOST = '192.168.0.1' #gethostbyname(gethostname())
PORT = 2727
BUFFSIZE = 1024
ADDR = (HOST,PORT)

# Server Janjan
print "------------------------------------------------"
print "; Server Started ! =",HOST,":",PORT
print "------------------------------------------------"

# main..
main = socket(AF_INET,SOCK_STREAM)
main.bind(ADDR)
main.listen(1)

log = open("log.txt","w")
log.write(HOST)
log.close()

while True:
    service,(ip,port) = main.accept()
    print "----------------------------------"
    print "IP : ",ip
    while True:
        a = service.recv(BUFFSIZE)
        if a == '':
            print "Connection rbp"
            break
    print "----------------------------------"














---------------




kane@pardus ~ $ python ./server.py
------------------------------------------------
; Server Started ! = 192.168.0.1 : 2727
------------------------------------------------
----------------------------------
IP :  192.168.0.1
Connection rbp