Send data by packet on socket
507761
def send_by_packet(self, data):
        
        total_sent = 0
        while total_sent < PACKET_SIZE:
            sent = self.sock.send(data[total_sent:])
            if sent == 0:
                raise RuntimeError("socket connection broken")
            total_sent += sent
        return total_sent
721300
def send_packet(self, packet, queue=True):
        

        if not isinstance(packet, RTMPPacket):
            raise ValueError("A RTMPPacket argument is required")

        return librtmp.RTMP_SendPacket(self.rtmp, packet.packet,
                                       int(queue))
302732
def send_packet(self, dev, packet):
        '''
        
        '''
        if packet is None:
            raise ValueError("No packet object given to send_packet")
        if not isinstance(packet, Packet):
            raise ValueError("Object given to send_packet is not a Packet (it is: {})".format(type(packet)))
 
        intf = None
        if isinstance(dev, int):
           dev = self._lookup_devname(dev)

        if isinstance(dev, Interface):
            intf = dev
            dev = dev.name
        elif dev in self._devinfo:
            intf = self.interface_by_name(dev)
        else:
            raise ValueError("Unrecognized device name for packet send: {}".format(dev))

        if intf.iftype == InterfaceType.Loopback:
            pdev = self._localsend.get(dev, None)
            pdev.send_packet(packet)
        else:
            pdev = self._pcaps.get(dev, None)
            rawpkt = packet.to_bytes()
            log_debug("Sending packet on device {}: {}".format(dev, str(packet)))
            pdev.send_packet(rawpkt)
935167
def send(self, data):
        """"""
        # send message
        _LOGGER.debug("send: " + data)
        self.socket.send(data.encode('ascii'))
        # sleep needed to prevent flooding the GC100 with sends
        sleep(.01)
219270
def send(socket, data, num_bytes=20):
    
    pickled_data = pickle.dumps(data, -1)
    length = str(len(pickled_data)).zfill(num_bytes)
    socket.sendall(length.encode())
    socket.sendall(pickled_data)
304365
def _stream_send_and_receive(self, _socket, message, *args, **kwargs):
        """"""
        data = BytesIO()

        _socket_fd = _socket.makefile(mode='rwb', encoding='utf-8')
        _socket_fd.write(message.encode('utf-8'))
        _socket_fd.flush()

        for received in _socket_fd:
            data.write(received)
        data.seek(0)

        _socket_fd.close()
        return data
1370428
def socket_send(
        sock,
        msg,
        debug=False):
    
    if IS_PY2:
        sock.send(msg)
    else:
        sock.send(msg.encode())
1263183
def send(self, data):
        
        try:
            self.socket.sendto(data.encode('utf8') + b'\n', (self.host, self.port))
        except (socket.error, RuntimeError):
            # Socket errors should fail silently so they don't affect anything else
            pass
822034
void sendBufferSync(ByteBuffer bb) {
       try {
           /* configure socket to be blocking
            * so that we dont have to do write in
            * a tight while loop
            */
           sock.configureBlocking(true);
           if (bb != closeConn) {
               if (sock != null) {
                   sock.write(bb);
               }
               packetSent();
           }
       } catch (IOException ie) {
           LOG.error("Error sending data synchronously ", ie);
       }
    }
1300789
def send(self, data):
        """"""
        log.debug('Sending %s' % data)
        if not self._socket:
            log.warn('No connection')
            return
        self._socket.send_bytes(data.encode('utf-8'))
1091685
function Packet(e) {
    if(e instanceof Buffer) {
        this.data   = e;
        this.length = this.data.length;
    }else if((typeof Buffer) != 'undefined' && e.data instanceof Buffer) {
        this.data   = e.data;
        this.length = this.data.length;
    }else{
        this.data   = new DataView(e.data);
        this.length = this.data.byteLength;
    }

    this.offset = 0;
}
1106451
def _dgram_send_and_receive(self, _socket, message, buffer_size=4096, *args):
        """"""
        _socket.send(message.encode('utf-8'))
        data, address = _socket.recvfrom(buffer_size)
        return BytesIO(data)
218794
def sendto(self, data, addr=None):
        
        if not isinstance(data, (bytes, bytearray, memoryview)):
            raise TypeError("data: expecting a bytes-like instance, got {!r}"
                                .format(type(data).__name__))
        self._check_status()
        if not self._writable:
            raise TransportError('transport is not writable')
        try:
            self._handle.send(addr, data, self._on_send_complete)
        except pyuv.error.UVError as e:
            error = TransportError.from_errno(e.args[0])
            # Try to discern between permanent and transient errors. Permanent
            # errors close the transport. This list is very likely not complete.
            if error.errno != pyuv.errno.UV_EBADF:
                raise error
            self._error = error
            self.abort()
        self._write_buffer_size += 1
        self._maybe_pause_protocol()
892581
def _get_packet(self, socket):
        
        data, (ip, port) = socket.recvfrom(self._buffer_size)
        packet, remainder = self._unpack(data)
        self.inbox.put((ip, port, packet))
        self.new_packet.set()
        self.debug(u"RX: {}".format(packet))

        if packet.header.sequence_number is not None:
            # Packet needs to be acknowledged
            self._send_ack(ip, port, packet)
        ack_seq = packet.header.ack_sequence_number
        if ack_seq is not None:
            # Packet got acknowledged
            with self._seq_ack_lock:
                if ack_seq in self._seq_ack:
                    self.debug(u"Seq {} got acked".format(ack_seq))
                    self._seq_ack.remove(ack_seq)
        return packet
1336600
public static void sendBlockData(Chunk chunk, String identifier, ByteBuf data, EntityPlayerMP player)
	{
		MalisisCore.network.sendTo(new Packet(chunk, identifier, data), player);
	}
1322830
function ondata(chunk) {
    packet.push(chunk);
    if (packet.isReady()) {
      if (self._state.sessionId !== packet.header.sessionId) {
        self._state.sessionId = packet.header.sessionId;
        self._state.packetCount = -1;
      }
      var buffer = packet.getData();
      packet.clear();
      var cb = self._state.receive;
      self._state.receive = undefined;
      self._state.messageType = undefined;
      self.receive(buffer, cb);
    }
  }
310094
function send (event, data) {
    var envelope = {
      event: event,
      data: data
    };
    debug('send', envelope);
    socket.send(JSON.stringify(envelope));
  }