-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3b6a72
commit 102fe08
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import socket | ||
|
||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
|
||
host = socket.gethostname() | ||
port = 8080 | ||
|
||
s.connect((host, port)) | ||
|
||
tm = s.recv(1024) | ||
print("The client is waiting for connection") | ||
s.close() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import socket | ||
import time | ||
|
||
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
|
||
host = socket.gethostname() | ||
port = 8080 | ||
|
||
serversocket.bind((host, port)) | ||
|
||
serversocket.listen(5) | ||
|
||
while True: | ||
clientsocket,addr = serversocket.accept() | ||
print("Got a connection from %s" % str(addr)) | ||
currentTime = time.ctime(time.time()) + "\r\n" | ||
clientsocket.send(currentTime.encode('ascii')) | ||
clientsocket.close() |