Creates a datagram socket
511100
protected synchronized void create() throws SocketException {
        ResourceManager.beforeUdpCreate();
        fd = new FileDescriptor();
        try {
            datagramSocketCreate();
        } catch (SocketException ioe) {
            ResourceManager.afterUdpClose();
            fd = null;
            throw ioe;
        }

        if (fd != null && fd.valid()) {
            guard.open("close");
        }
    }
836844
def datagram_received(self, data, addr):
        """"""
        #_LOGGER.debug(data)
        if not self.box_ip or self.box_ip == addr[0]:
            self.responses(MediaroomNotify(addr, data))
939976
public Socket createSocket(SocketType type)
    {
        // Create and register socket
        Socket socket = context.socket(type);
        socket.setRcvHWM(this.rcvhwm);
        socket.setSndHWM(this.sndhwm);
        sockets.add(socket);
        return socket;
    }
897829
function sendMyInfo(senderMessage, senderInfo) {

        if (mode == "listen") {
            return;
        }

        var message = createMessage("ONE");
        var socket = dgram.createSocket({ type: 'udp4', reuseAddr: true });

        socket.bind(function() {
            socket.send(message, 0, message.length, senderMessage.port, senderInfo.address, function(err, bytes) {
                socket.close();
            });
        });

    }
1016391
private static void bind(final NioDatagramChannel channel,
                             final ChannelFuture future, final InetSocketAddress address) {
        boolean bound = false;
        boolean started = false;
        try {
            // First bind the DatagramSocket the specified port.
            channel.getDatagramChannel().socket().bind(address);
            bound = true;

            future.setSuccess();
            fireChannelBound(channel, address);

            channel.worker.register(channel, null);
            started = true;
        } catch (final Throwable t) {
            future.setFailure(t);
            fireExceptionCaught(channel, t);
        } finally {
            if (!started && bound) {
                close(channel, future);
            }
        }
    }
231170
def _write_callback(connection_id, data_buffer, data_length_pointer):
    
    wrapped_socket = None
    try:
        wrapped_socket = _connection_refs.get(connection_id)
        if wrapped_socket is None:
            return SecurityConst.errSSLInternal
        base_socket = wrapped_socket.socket

        bytes_to_write = data_length_pointer[0]
        data = ctypes.string_at(data_buffer, bytes_to_write)

        timeout = wrapped_socket.gettimeout()
        error = None
        sent = 0

        try:
            while sent < bytes_to_write:
                if timeout is None or timeout >= 0:
                    if not util.wait_for_write(base_socket, timeout):
                        raise socket.error(errno.EAGAIN, 'timed out')
                chunk_sent = base_socket.send(data)
                sent += chunk_sent

                # This has some needless copying here, but I'm not sure there's
                # much value in optimising this data path.
                data = data[chunk_sent:]
        except (socket.error) as e:
            error = e.errno

            if error is not None and error != errno.EAGAIN:
                data_length_pointer[0] = sent
                if error == errno.ECONNRESET or error == errno.EPIPE:
                    return SecurityConst.errSSLClosedAbort
                raise

        data_length_pointer[0] = sent

        if sent != bytes_to_write:
            return SecurityConst.errSSLWouldBlock

        return 0
    except Exception as e:
        if wrapped_socket is not None:
            wrapped_socket._exception = e
        return SecurityConst.errSSLInternal
1273305
private static Channel createChannel() throws IOException {

        // dup the file descriptor - we do this so that for two reasons :-
        // 1. Avoids any timing issues with FileDescriptor.in being closed
        //    or redirected while we create the channel.
        // 2. Allows streams based on file descriptor 0 to co-exist with
        //    the channel (closing one doesn't impact the other)

        int fdVal = dup(0);

        // Examine the file descriptor - if it's not a socket then we don't
        // create a channel so we release the file descriptor.

        int st;
        st = soType0(fdVal);
        if (st != SOCK_STREAM && st != SOCK_DGRAM) {
            close0(fdVal);
            return null;
        }


        // Next we create a FileDescriptor for the dup'ed file descriptor
        // Have to use reflection and also make assumption on how FD
        // is implemented.

        Class paramTypes[] = { int.class };
        Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor",
                                                    paramTypes);
        Object args[] = { new Integer(fdVal) };
        FileDescriptor fd = (FileDescriptor)Reflect.invoke(ctr, args);


        // Now create the channel. If the socket is a streams socket then
        // we see if tthere is a peer (ie: connected). If so, then we
        // create a SocketChannel, otherwise a ServerSocketChannel.
        // If the socket is a datagram socket then create a DatagramChannel

        SelectorProvider provider = SelectorProvider.provider();
        assert provider instanceof sun.nio.ch.SelectorProviderImpl;

        Channel c;
        if (st == SOCK_STREAM) {
            InetAddress ia = peerAddress0(fdVal);
            if (ia == null) {
               c = new InheritedServerSocketChannelImpl(provider, fd);
            } else {
               int port = peerPort0(fdVal);
               assert port > 0;
               InetSocketAddress isa = new InetSocketAddress(ia, port);
               c = new InheritedSocketChannelImpl(provider, fd, isa);
            }
        } else {
            c = new InheritedDatagramChannelImpl(provider, fd);
        }
        return c;
    }
201200
function createSocketInfoFile(channelName, readerUuid, paths) {
    const pathToFile = socketInfoPath(channelName, readerUuid, paths);
    return writeFile(
        pathToFile,
        JSON.stringify({
            time: microSeconds()
        })
    ).then(() => pathToFile);
}
334364
SocketChannel createSock() throws IOException {
        SocketChannel sock;
        sock = SocketChannel.open();
        sock.configureBlocking(false);
        sock.socket().setSoLinger(false, -1);
        sock.socket().setTcpNoDelay(true);
        return sock;
    }
781945
def _createSocket(self, port):
        '''
        
        '''
        self._logger.info(
            'Setting up UDP socket to listen to port {:}'.format(port))
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        sock.settimeout(self._timeout)
        self._logger.info(
            'Successfully set socket timeout to {_timeout}'
            .format(**self.__dict__))

        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self._logger.info('Successfully set socket option to SO_REUSEADDR')

        sock.bind(('', port))
        self._logger.info(
            'Successfully bound socket to ("", {port})'
            .format(port=port, **self.__dict__))

        return sock
44534
def send(self, jsonstr):
        
        udp_sock = socket(AF_INET, SOCK_DGRAM)
        udp_sock.sendto(jsonstr.encode('utf-8'), self.addr)
276415
def _create_listening_stream(self, pull_addr):
        
        sock = self._zmq_context.socket(zmq.PULL)
        sock.connect(pull_addr)
        stream = ZMQStream(sock, io_loop=self.io_loop)

        return stream
23335
private SocketIOChannel create(InetSocketAddress localAddress, TCPConnLink tcpConnLink) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "create");
        }

        SocketIOChannel ioSocket = tcpChannel.createOutboundSocketIOChannel();
        Socket socket = ioSocket.getSocket();
        TCPChannelConfiguration tcpConfig = this.tcpChannel.getConfig();

        socket.setReuseAddress(tcpConfig.getSoReuseAddress());

        if ((tcpConfig.getReceiveBufferSize() >= RECEIVE_BUFFER_SIZE_MIN) && (tcpConfig.getReceiveBufferSize() <= RECEIVE_BUFFER_SIZE_MAX)) {
            socket.setReceiveBufferSize(tcpConfig.getReceiveBufferSize());
        }

        if ((tcpConfig.getSendBufferSize() >= SEND_BUFFER_SIZE_MIN) && (tcpConfig.getSendBufferSize() <= SEND_BUFFER_SIZE_MAX)) {
            socket.setSendBufferSize(tcpConfig.getSendBufferSize());
        }

        // need this check, or else the getLocalAddress call will return all zeroes
        // if we bind with a null localAddress here
        if (localAddress != null) {
            try {
                socket.bind(localAddress);

                InetAddress ia = localAddress.getAddress();
                if (ia != null) {
                    ConnectionDescriptor cd = tcpConnLink.getVirtualConnection().getConnectionDescriptor();

                    if (cd != null) {
                        cd.setAddrs(null, ia);
                    } else {
                        ConnectionDescriptorImpl cdi = new ConnectionDescriptorImpl(null, ia);
                        tcpConnLink.getVirtualConnection().setConnectionDescriptor(cdi);
                    }

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "bound connection: " + tcpConnLink.getVirtualConnection().getConnectionDescriptor());
                    }
                }

            } catch (IOException ioe) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Bind error making outbound connection " + ioe);
                }

                if (socket != null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Socket closed on bind exception.");
                    }
                    socket.close();
                }

                FFDCFilter.processException(ioe, getClass().getName(), "create", this);
                throw ioe;
            }
        }

        if (tcpConfig.getSoLinger() >= 0) {
            socket.setSoLinger(true, tcpConfig.getSoLinger());
        } else {
            socket.setSoLinger(false, 0);
        }

        socket.setKeepAlive(tcpConfig.getKeepAlive());

        socket.setTcpNoDelay(tcpConfig.getTcpNoDelay());

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Socket created, local port: " + socket.getLocalPort());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "create");
        }

        return ioSocket;
    }
258576
def server(self):
        
        server = getattr(self, "_server", None)
        if server is None:
            log.debug("Binding datagram server to %s", self.bind)
            server = DatagramServer(self.bind, self._response_received)
            self._server = server
        return server
50371
public synchronized void writeDatagram (Message datagram)
        throws IOException
    {
        // first write the sequence and acknowledge numbers
        _uout.writeInt(++_lastNumber);
        _uout.writeInt(_lastReceived);

        // make sure the mapped sets are clear
        Set<Class<?>> mappedClasses = _uout.getMappedClasses();
        mappedClasses.clear();
        Set<String> mappedInterns = _uout.getMappedInterns();
        mappedInterns.clear();

        // write the object
        _uout.writeObject(datagram);

        // if we wrote any class mappings, we will keep them in the send record
        if (mappedClasses.isEmpty()) {
            mappedClasses = null;
        } else {
            _uout.setMappedClasses(new HashSet<Class<?>>());

        }

        // likewise with the intern mappings
        if (mappedInterns.isEmpty()) {
            mappedInterns = null;
        } else {
            _uout.setMappedInterns(new HashSet<String>());

        }

        // record the transmission
        _sendrecs.add(new SendRecord(_lastNumber, mappedClasses, mappedInterns));
    }
259483
public static DataBuffer create(final int type, final int size, final int numBanks) throws IOException {
        switch (type) {
            case DataBuffer.TYPE_BYTE:
                return new DataBufferByte(size, numBanks);
            case DataBuffer.TYPE_USHORT:
                return new DataBufferUShort(size, numBanks);
            case DataBuffer.TYPE_INT:
                return new DataBufferInt(size, numBanks);
            default:
                throw new IllegalArgumentException("Unsupported data type: " + type);
        }
    }
51513
static ClientDatanodeProtocol createClientDatanodeProtocolProxy (
      DatanodeInfo datanodeid, Configuration conf) throws IOException {
    InetSocketAddress addr = NetUtils.createSocketAddr(
      datanodeid.getHost() + ":" + datanodeid.getIpcPort());
    if (ClientDatanodeProtocol.LOG.isDebugEnabled()) {
      ClientDatanodeProtocol.LOG.info("ClientDatanodeProtocol addr=" + addr);
    }
    try {
      return (ClientDatanodeProtocol)RPC.getProxy(ClientDatanodeProtocol.class,
        ClientDatanodeProtocol.versionID, addr, conf);
    } catch (RPC.VersionMismatch e) {
      long clientVersion = e.getClientVersion();
      long datanodeVersion = e.getServerVersion();
      if (clientVersion > datanodeVersion &&
          !ProtocolCompatible.isCompatibleClientDatanodeProtocol(
              clientVersion, datanodeVersion)) {
        throw new RPC.VersionIncompatible(
            ClientDatanodeProtocol.class.getName(), clientVersion, datanodeVersion);
      }
      return (ClientDatanodeProtocol)e.getProxy();
    }
  }