-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver2.py
More file actions
34 lines (27 loc) · 761 Bytes
/
server2.py
File metadata and controls
34 lines (27 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import socket
# Target IP address of android device
HOST = '192.168.1.35'
PORT = 45104
pcIP = socket.gethostbyname(socket.gethostname())
print("PC IP: " + pcIP)
HOST = pcIP #garanticilik
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #SOCK_STREAM
s.bind((HOST,PORT))
print("binded...")
s.listen(1) #en fazla 1 baglanti kabul et
print("listening...")
conn, addr = s.accept()
print("connected by " + addr[0])
print(f'the connection variable= {conn}\n')
while 1:
print("veri yazdirma basladi...")
data = conn.recv(1024).decode()
print("mesaj alindi")
if not data:
print("veri bos")
break
print("data: " + data)
#conn.sendall(data)
conn.close()
print("baglanti sonlandirildi")
print("donguden cikildi")