Skip to content

Commit 00c2438

Browse files
committed
add HTTP header and MSG
1 parent 86985ed commit 00c2438

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

server.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33

44

55
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6-
6+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
77
host = socket.gethostname()
88
port = int(sys.argv[1])
9-
sock.bind(('192.168.43.219', port))
9+
sock.bind(('localhost', port))
1010
sock.listen(5)
1111
print 'server listening on 192.168.43.219:%s'% port
1212
while True:
13-
c, add = sock.accept()
14-
print 'connection from ', add
15-
c.send("""
16-
<html>
17-
<h1>cieee connect ke server gw ciee </h1>
18-
</html>
13+
client_connection, address = sock.accept()
14+
print 'connection from ', address
15+
client_connection.sendall("""\
16+
HTTP/1.1 200 OK
17+
18+
Hello, World
1919
""")
20+
client_connection.close()
21+
2022

2123

2224

0 commit comments

Comments
 (0)