Skip to content

Commit 6a38101

Browse files
Socket initial commit
1 parent ab8db3a commit 6a38101

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

PyGame/Introduction/mu.png

1.05 KB
Loading

SocketPrograms/simpleClient.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import socket # Import socket module
2+
3+
s = socket.socket() # Create a socket object
4+
host = socket.gethostname() # Get local machine name
5+
port = 12345 # Reserve a port for your service.
6+
7+
s.connect((host, port))
8+
print (s.recv(1024))
9+
s.close # Close the socket when done

SocketPrograms/simpleServer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import socket # Import socket module
2+
3+
s = socket.socket() # Create a socket object
4+
host = socket.gethostname() # Get local machine name
5+
port = 12345 # Reserve a port for your service.
6+
s.bind((host, port)) # Bind to the port
7+
8+
s.listen(5) # Now wait for client connection.
9+
while True:
10+
c, addr = s.accept() # Establish connection with client.
11+
print ('Got connection from', addr)
12+
c.send('Thank you for connecting')
13+
c.close() # Close t

0 commit comments

Comments
 (0)