-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PyObject::__toString() for python bytes
- Loading branch information
Showing
6 changed files
with
66 additions
and
10 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,22 @@ | ||
<?php | ||
$socket = PyCore::import('socket'); | ||
|
||
const HOST = "127.0.0.1"; | ||
const PORT = 5432; | ||
|
||
$client = $socket->socket($socket->AF_INET, $socket->SOCK_STREAM); | ||
$client->connect(PyCore::tuple([HOST, PORT])); | ||
|
||
while (1) { | ||
echo "> "; | ||
$msg = trim(fgets(STDIN)); | ||
if ($msg == 'quit') { | ||
break; | ||
} | ||
$client->sendall(PyCore::bytes($msg)); | ||
$data = $client->recv(1024); | ||
if (empty($data)) { | ||
break; | ||
} | ||
echo strval($data) . PHP_EOL; | ||
} |
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,16 @@ | ||
import socket | ||
|
||
HOST = "127.0.0.1" | ||
PORT = 5432 | ||
|
||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.bind((HOST, PORT)) | ||
s.listen() | ||
conn, addr = s.accept() | ||
with conn: | ||
print(f"Connected by {addr}") | ||
while True: | ||
data = conn.recv(1024) | ||
if not data: | ||
break | ||
conn.sendall(data) |
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
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
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
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