Last active
June 15, 2020 15:06
-
-
Save harsh-98/18e19e467d7f2bf9c5745af2db68457c to your computer and use it in GitHub Desktop.
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
import socket | |
class MySocket: | |
def __init__(self, sock=None): | |
if sock is None: | |
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
else: | |
self.sock = sock | |
def connect(self, host, port): | |
self.sock.connect((host, port)) | |
def mysend(self, msg): | |
self.sock.send(msg.encode('utf-8')) | |
def myreceive(self): | |
return self.sock.recv(4096) | |
msg='{"jsonrpc": "2.0","method": "nodeStats", "id": "1"}\n' | |
s = MySocket() | |
s.connect("127.0.0.1", 21338) | |
s.mysend(msg) | |
print(s.myreceive()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment