Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Network.py socket

import socket
import pickle


class Network:
    def __init__(self):
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server = "10.11.250.207"
        self.port = 5555
        self.addr = (self.server, self.port)
        self.p = self.connect()

    def getP(self):
        return self.p

    def connect(self):
        try:
            self.client.connect(self.addr)
            return pickle.loads(self.client.recv(2048))
        except:
            pass

    def send(self, data):
        try:
            self.client.send(pickle.dumps(data))
            return pickle.loads(self.client.recv(2048))
        except socket.error as e:
            print(e)
Comment

PREVIOUS NEXT
Code Example
Python :: how to input comma separated int values in python 
Python :: python get system information 
Python :: pandas shift columns up until value 
Python :: how to use python to sleep if the user is not using the system 
Python :: django modelform style 
Python :: tkinter window background color 
Python :: cv2 yellow color range 
Python :: pyqt5 line edit password input 
Python :: filter dataframe 
Python :: how to make a pythoon turtle follow another? 
Python :: isinstance float or int 
Python :: how to save unzipped files in python 
Python :: django template tags capitalize 
Python :: send email with flask 
Python :: how to seperate words and number in a list 
Python :: install hydra python 
Python :: adjust size of plot 
Python :: python hello world 
Python :: python defaultdict 
Python :: python get current month 
Python :: django jalali date 
Python :: python matplotlib pyplot 
Python :: how to add subplots for histogram 
Python :: from imblearn.over_sampling import smote error 
Python :: How to install XGBoost package in python on Windows 
Python :: python bash command 
Python :: python multithreading tutorials 
Python :: pyqt5 qlineedit on change 
Python :: python get name of function 
Python :: how to make html files open in chrome using python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =