<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect(self):
 """ Connects to Scratch. """

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            self.socket.connect((self.host, self.port))
        except socket.error as (err, msg):
            self.connected = False
            raise ScratchError("[Errno %d] %s" % (err, msg))
        self.connected = True