open the connection (if not already opened) and send
761895
public function _open($opentimeout = 0.0, $waittimeout = 5.0)
    {
        global $_web_access_retry_timeout_max;

        if (!isset($this->_spool[0]['State'])) {
            return false;
        }
        $time = time();

        // if async, in error, then return false until timeout or if > max)
        if (!$this->_wait && $this->_state == 'BAD' &&
            (($this->_bad_timeout > $_web_access_retry_timeout_max) ||
                (($time - $this->_bad_time) < $this->_bad_timeout))) {
            $this->console->writeln($this->_webaccess_str.'wait to retry ('.($time - $this->_bad_time).' / '.$this->_bad_timeout.')');

            return false;
        }

        // if the socket is probably in timeout, close it
        if ($this->_socket && $this->_state == 'OPENED' &&
            ($this->_serv_keepalive_timeout <= ($time - $this->_query_time))) {

            $this->console->writeln($this->_webaccess_str.'timeout, closed it!');
            $this->_state = 'CLOSED';
            @fclose($this->_socket);
            $this->_socket = null;
        }

        // if socket is not opened, open it
        if (!$this->_socket || $this->_state != 'OPENED') {
            $this->_open_socket($opentimeout);
        }

        // if socket is open, send data if possible
        if ($this->_socket) {
            $this->_read_time = microtime(true);

            // if wait (synchronous query) then go on all pending write/read until the last
            if ($this->_wait) {
                @stream_set_timeout($this->_socket, 0, 10000);

                while (isset($this->_spool[0]['State']) &&
                    ($this->_spool[0]['State'] == 'OPEN' ||
                        $this->_spool[0]['State'] == 'SEND' ||
                        $this->_spool[0]['State'] == 'RECEIVE')) {
                    echo 'State='.$this->_spool[0]['State']." (".count($this->_spool).")\n";
                    if (!$this->_socket || $this->_state != 'OPENED') {
                        $this->_open_socket($opentimeout);
                    }

						$query_state = $this->_spool[0]['State'];
                    if ($this->_spool[0]['State'] == 'OPEN') {
                        $time = microtime(true);
                        $this->_spool[0]['Times']['send'][0] = $time;
                        $this->_send($waittimeout);
                    } elseif ($this->_spool[0]['State'] == 'SEND') {
                        $this->_send($waittimeout);
                    } elseif ($this->_spool[0]['State'] == 'RECEIVE') {
                        $this->_receive($waittimeout * 4);
                    }

                    // if timeout then error
                    if ($query_state != 'RECEIVE' && ($difftime = microtime(true) - $this->_read_time) > $waittimeout) {
                        $this->_bad("Request timeout, in _open ({$difftime} > {$waittimeout}s) state=".$this->_spool[0]['State']
                        );

                        return;
                    }
                }
                if ($this->_socket) {
                    @stream_set_timeout($this->_socket, 0, 2000);
                }
            } // else just do a send on the current
            elseif (isset($this->_spool[0]['State']) && $this->_spool[0]['State'] == 'OPEN') {
                @stream_set_timeout($this->_socket, 0, 2000);  // timeout 2 ms
                $this->_send($waittimeout);
            }
        }
    }
1348453
def send(self, send_string, newline=None):
        """"""
        self.current_send_string = send_string
        newline = newline if newline is not None else self.newline

        self.channel.send(send_string + newline)
794814
def send(self, msg):
        """"""
        def reconnect(e):
            self.log.error('send error, reconnecting...', exc_info=True)
            self.connect_ensime_server()
            if self.ws:
                self.ws.send(msg + "\n")

        self.log.debug('send: in')
        if self.running and self.ws:
            with catch(websocket.WebSocketException, reconnect):
                self.log.debug('send: sending JSON on WebSocket')
                self.ws.send(msg + "\n")
956552
def open(self) -> bool:
        
        if self.connection:
            # Nothing to do if the connection is already open.
            return False

        connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
        if self.timeout is not None:
            connection_params['timeout'] = self.timeout
        try:
            self.connection = smtplib.SMTP(self.host, self.port,
                                           **connection_params)

            # TLS
            context = ssl.SSLContext(self._protocol())
            if self.ssl_certfile:
                context.load_cert_chain(certfile=self.ssl_certfile,
                                        keyfile=self.ssl_keyfile)
            self.connection.ehlo()
            self.connection.starttls(context=context)
            self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(self.username, self.password)
                log.debug("Successful SMTP connection/login")
            else:
                log.debug("Successful SMTP connection (without login)")
            return True
        except smtplib.SMTPException:
            log.debug("SMTP connection and/or login failed")
            if not self.fail_silently:
                raise
48702
def sendOACK(self):
        """"""
        log.debug("In sendOACK with options %s", self.context.options)
        pkt = TftpPacketOACK()
        pkt.options = self.context.options
        self.context.sock.sendto(pkt.encode().buffer,
                                 (self.context.host,
                                  self.context.tidport))
        self.context.last_pkt = pkt
728789
def open(self):
		
		if self.connection:
			# Nothing to do if the connection is already open.
			return False

		self.connection = self._get_twilio_client()
		return True
1301232
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT):
        """"""
        # This is a quick test to see if we can parse the packets we generate
        #temp = DNSIncoming(out.packet())
        for i in self.intf.values():
            try:
                return i.sendto(out.packet(), 0, (addr, port))
            except:
                traceback.print_exc()
                # Ignore this, it may be a temporary loss of network connection
                return -1
559164
def open(self):
        '''
        
        '''
        args = Writer()
        args.write_shortstr('')
        self.send_frame(MethodFrame(self.channel_id, 20, 10, args))
        self.channel.add_synchronous_cb(self._recv_open_ok)
1120484
def send(self, data):
        
        if self.readyState != 'open':
            raise InvalidStateError

        if not isinstance(data, (str, bytes)):
            raise ValueError('Cannot send unsupported data type: %s' % type(data))

        self.transport._data_channel_send(self, data)
1137355
def send(self):
        

        if hasattr(self, 'request'):
            self.request.responded = True
        self.connection.writer.write(str(self).encode())
        yield from self.connection.writer.drain()
1029164
async def _send_loop(self):
        
        while self._user_connected and not self._reconnecting:
            if self._pending_ack:
                ack = RequestState(MsgsAck(list(self._pending_ack)), self._loop)
                self._send_queue.append(ack)
                self._last_acks.append(ack)
                self._pending_ack.clear()

            self._log.debug('Waiting for messages to send...')
            # TODO Wait for the connection send queue to be empty?
            # This means that while it's not empty we can wait for
            # more messages to be added to the send queue.
            batch, data = await self._send_queue.get()

            if not data:
                continue

            self._log.debug('Encrypting %d message(s) in %d bytes for sending',
                          len(batch), len(data))

            data = self._state.encrypt_message_data(data)
            try:
                await self._connection.send(data)
            except IOError as e:
                self._log.info('Connection closed while sending data')
                self._start_reconnect(e)
                return

            for state in batch:
                if not isinstance(state, list):
                    if isinstance(state.request, TLRequest):
                        self._pending_state[state.msg_id] = state
                else:
                    for s in state:
                        if isinstance(s.request, TLRequest):
                            self._pending_state[s.msg_id] = s

            self._log.debug('Encrypted messages put in a queue to be sent')
1289730
def open(self):
        
        self._sendCmd(self.REG_PWR_MGMT_1, 0x00)
        self._sendCmd(self.REG_PWR_MGMT_2, 0x00)
1367590
public int send (Connection connection, Object object) throws IOException {
		SocketChannel socketChannel = this.socketChannel;
		if (socketChannel == null) throw new SocketException("Connection is closed.");
		synchronized (writeLock) {
			int start = writeBuffer.position();
			int lengthLength = serialization.getLengthLength();
			try {
				// Leave room for length.
				writeBuffer.position(writeBuffer.position() + lengthLength);

				// Write data.
				serialization.write(connection, writeBuffer, object);
			} catch (Throwable ex) {
				throw new KryoNetException("Error serializing object of type: " + object.getClass().getName(), ex);
			}
			int end = writeBuffer.position();

			// Write data length.
			writeBuffer.position(start);
			serialization.writeLength(writeBuffer, end - lengthLength - start);
			writeBuffer.position(end);

			// Write to socket if no data was queued.
			if (start == 0 && !writeToSocket()) {
				// A partial write, set OP_WRITE to be notified when more writing can occur.
				selectionKey.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
			} else {
				// Full write, wake up selector so idle event will be fired.
				selectionKey.selector().wakeup();
			}

			if (DEBUG || TRACE) {
				float percentage = writeBuffer.position() / (float)writeBuffer.capacity();
				if (DEBUG && percentage > 0.75f)
					debug("kryonet", connection + " TCP write buffer is approaching capacity: " + percentage + "%");
				else if (TRACE && percentage > 0.25f)
					trace("kryonet", connection + " TCP write buffer utilization: " + percentage + "%");
			}

			lastWriteTime = System.currentTimeMillis();
			return end - start;
		}
	}
1177429
private function connect()
    {
        if (!$this->socket->isOpened()) {
            $this->socket->open();

            if ($this->secret) {
                $this->socket->send(join(Driver::SEP, ['A', 1, Driver::encode($this->secret)]).Driver::EOL);
            }
        }
    }
138112
def send(frame)
      if Frame::Data === frame
        @send_buffer << frame
        if @send_remaining_window < frame.length
          if Stream === self
            connection.callback(:send_deferred, self, frame)
          else
            callback(:send_deferred, self, frame)
          end
        else
          consume_send_buffer
        end
      else
        send_immediately frame
      end
    end
435319
def send(self, data):
        
        sock = socket.socket(*self.sock_args)
        try:
            sock.connect(self.sock_addr)
        except socket.error as exc:
            raise socket.error("Can't connect to %r (%s)" % (self.url.geturl(), exc))

        try:
            # Send request
            sock.send(data)

            # Read response
            while True:
                chunk = sock.recv(self.CHUNK_SIZE)
                if chunk:
                    yield chunk
                else:
                    break
        finally:
            # Clean up
            sock.close()
865301
def send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs):
    """"""
    __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)