import socket
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
_socket.connect(('data.pr4e.org', 80))
print("Own address : ", _socket.getsockname())
print("Remote address : ", _socket.getpeername())
print()
cmd = "GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n".encode() # \r\n\r\n 꼭 있어야 한다.
_socket.send(cmd)
while True :
data = _socket.recv(512)
#print("==>", data.decode())
#if len(data) < 1 : <- 이렇게 해도된다. but data is None 은 안된다. 마지막 문자는 공백('')이다.
if not data :
break
print(data.decode(), end="")
_socket.close()
-------------------------------------------------------------
Own address : ('192.168.0.3', 1917)
Remote address : ('192.241.136.170', 80)
HTTP/1.1 200 OK
Date: Tue, 27 Aug 2019 11:35:58 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Sat, 13 May 2017 11:22:22 GMT
ETag: "a7-54f6609245537"
Accept-Ranges: bytes
Content-Length: 167
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Connection: close
Content-Type: text/plain
But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief
Socket
|
2019.08.28 07:23:01
|
2019.08.29 00:48:15
|
298
|
Aiden
Total of Attached file
0.00 Bytes of 0 files
2019.08.30
2019.08.30
2019.08.30
2019.08.29
2019.08.29
2019.08.28
2019.08.23
2019.08.23
2019.08.21
2019.08.21
2017.03.18