:meth:`.WNetworkNativeTransportProto.bind_socket` method implementation
490180
def bind_socket(self, config):
		
		address = config[self.__bind_socket_config.section][self.__bind_socket_config.address_option]
		port = config.getint(self.__bind_socket_config.section, self.__bind_socket_config.port_option)
		return WIPV4SocketInfo(address, port)
299468
def server_bind(self):
        
        TCPServer.server_bind(self)
        host, port = self.socket.getsockname()[:2]
        self.server_port = port
        try:
            self.server_name = socket.getfqdn(host)
        except ValueError:
            # Use the local host name in case of error, like CPython does
            self.server_name = socket.gethostname()
748432
function bindSocket(io, indicator) {
    Object.keys(indicator.watch).forEach((key) => {
        let eventName = indicator.watch[key];
        indicator.on(eventName, (msg) => io.emit(eventName, msg));
    });
}
1241424
function connection(socket){
	this.socket = socket;
	if (!!this.options.encoding) socket.setEncoding(this.options.encoding);
	socket.on('data', this.emit.bind(this, 'data'));
	this.emit('connection', socket);
}
1076783
function TcpConnect (socket) {
    this.count ++;    // increment client count inside this server
    socket.uid = "Socket://" + socket.remoteAddress +":" + socket.remotePort;
    socket.controller = this.controller;
    socket.adapter   = this.adapter;
    socket.controller.Debug(4, "N°:%d Server=[%s] Client: [%s]"
             ,this.count,this.uid,socket.uid);            
        
    // attach new device object to client socket
    socket.device = new TcpClient (socket);
    
    // notify adapter that it has a new client device connected
    if (socket.adapter.ClientConnect (socket) === -1) {
        try {socket.end();} catch(e){};
        return;
    }
  
    // send any received data to device parser
    socket.on(this.evtname, function(buffer) {
	    socket.controller.Debug(7, "%s Data=[%s]", socket.device.uid, buffer);
        // call adapter specific method to process messages
        socket.adapter.ParseBuffer(socket, buffer);
    });
    
    // On error close socket
    socket.on('error', function (err) {
        socket.controller.Debug(3, "%s ERROR=[%s]", socket.device.uid, err);
        this.adapter.ClientQuit(socket);
        try {socket.destroy();} catch(e){};
    });
        
    // Remove the device from gateway active device list and notify adapter for eventual cleanup
    socket.on('end', function () {
	socket.controller.Debug(4, "SockClient Quit devid=%s uid=%s", socket.device.devid, socket.device.uid);
        this.adapter.ClientQuit(socket);
    });
    
}
169570
def _zmq_socket_context(context, socket_type, bind_endpoints):
    """"""
    socket = context.socket(socket_type)
    try:
        for endpoint in bind_endpoints:
            try:
                socket.bind(endpoint)
            except Exception:
                _logger.fatal("Could not bind to '%s'.", endpoint)
                raise
        yield socket
    finally:
        socket.close()
1158114
def setup_handler(self, io_loop):
		
		WNativeSocketHandler.setup_handler(self, io_loop)
		if self.server_mode() is False:
			self.io_handler().transport_socket().sendto(
				self.io_handler().messenger().request(self.config()),
				self.transport().target_socket(self.config()).pair()
			)
975526
@Override
    public void bind(SocketAddress bindpoint) throws IOException {
	super.bind(bindpoint);
	this.addr = (UNIXSocketAddress) bindpoint;
    }
743834
def connected_socket(address, timeout=3):
    
    sock = socket.create_connection(address, timeout)
    yield sock
    sock.close()
1122194
def resolve_real_bind_addr(socket_):
        """"""
        # FIXME: keep requested bind_addr separate real bound_addr (port
        # is different in case of ephemeral port 0)
        bind_addr = socket_.getsockname()
        if socket_.family in (
            # Windows doesn't have socket.AF_UNIX, so not using it in check
            socket.AF_INET,
            socket.AF_INET6,
        ):
            """UNIX domain sockets are strings or bytes.

            In case of bytes with a leading null-byte it's an abstract socket.
            """
            return bind_addr[:2]
        return bind_addr
543894
def socket_reader(connection: socket, buffer_size: int = 1024):
    
    while connection is not None:
        try:
            buffer = connection.recv(buffer_size)
            # no output
            if not len(buffer):
                raise ConnectionAbortedError
        except ConnectionAbortedError:
            # socket closed
            print('connection aborted')
            connection.close()
            yield None
        except OSError:
            # still operate connection after it was closed
            print('socket closed')
            connection.close()
            yield None
        else:
            yield buffer
959890
def _init_multicast_socket(self):
        
        self.debug("()")
        # Create a UDP socket
        self._multicast_socket = socket.socket(
            socket.AF_INET,
            socket.SOCK_DGRAM
        )

        # Allow reuse of addresses
        self._multicast_socket.setsockopt(
            socket.SOL_SOCKET,
            socket.SO_REUSEADDR,
            1
        )

        # Set multicast interface to local_ip
        self._multicast_socket.setsockopt(
            socket.IPPROTO_IP,
            socket.IP_MULTICAST_IF,
            socket.inet_aton(self._multicast_ip)
        )

        # Set multicast time-to-live
        # Should keep our multicast packets from escaping the local network
        self._multicast_socket.setsockopt(
            socket.IPPROTO_IP,
            socket.IP_MULTICAST_TTL,
            self._multicast_ttl
        )

        self._add_membership_multicast_socket()
        # Bind socket
        if platform.system().lower() == "darwin":
            self._multicast_socket.bind(("0.0.0.0", self._multicast_bind_port))
        else:
            self._multicast_socket.bind(
                (self._multicast_ip, self._multicast_bind_port)
            )
        self._listening.append(self._multicast_socket)
577058
def bind(self, source, dest, destmeth):
        
        self.connect(source, getattr(dest, destmeth))
1109521
private void doBind() throws Exception {
        LOG.debug("Creating listener socket");
        try {
            m_selector = Selector.open();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        ServerSocketChannel listenerSocket = ServerSocketChannel.open();
        InetSocketAddress inetsockaddr;
        if ((m_internalInterface == null) || (m_internalInterface.length() == 0)) {
            inetsockaddr = new InetSocketAddress(m_internalPort);
        }
        else {
            inetsockaddr = new InetSocketAddress(m_internalInterface, m_internalPort);
        }
        try {
            hostLog.info("Attempting to bind to internal ip " + inetsockaddr);
            listenerSocket.socket().bind(inetsockaddr);
            listenerSocket.configureBlocking(false);
            m_listenerSockets.add(listenerSocket);
        } catch (Exception e) {
            /*
             * If we bound to the leader address, the internal interface address  might not
             * bind if it is all interfaces
             */
            if (m_listenerSockets.isEmpty()) {
                LOG.fatal("Failed to bind to " + inetsockaddr);
                CoreUtils.printPortsInUse(hostLog);
                throw e;
            }
        }

        for (ServerSocketChannel ssc : m_listenerSockets) {
            ssc.register(m_selector, SelectionKey.OP_ACCEPT);
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Non-Primary Listening on:" + inetsockaddr.toString());
        }
    }
1177961
public void setSocket(Socket socket) {
	    if (socket != null)
	    {
	      m_remoteAddress = socket.getInetAddress();
	      this.port = socket.getPort();
	      m_controlThread = new DebugControlConnectionThread(socket, this);
	      m_controlThread.start();
	      executeStartupCommands();
	      m_controlThread.sendMessage("getsettings");

	      m_controlThread.sendMessage("[out-network");
	      //m_controlThread.sendMessage("[out-network-true");
	      String networkTracePortStr = m_controlThread.getMessage();
	      int networkTracePort = Integer.parseInt(networkTracePortStr);
	      if (LOG.isDebugEnabled()) LOG.debug("Received network trace port [" + networkTracePort + "]");
	      
	      try
	      {
	        INetworkOutputConfig config = new INetworkOutputConfig()
	        {
		          @Override
		          public boolean isNetOutputEnabled()
		          {
		            return m_settingsData.netOutEnabled;
		          }

				@Override
				public boolean isGzipEnabled() {
					return m_settingsData.gzipEnabled;
				}
	        };
	        	        
	        m_networkTraceThread2 = new NetworkDataReceiverThread2(
	        							m_remoteAddress,
	        							networkTracePort, 
	        							config
	        							);
	        m_networkTraceThread2.start();
		      setConnectState(ConnectState.CONNECTED);
		      setConnectionStatusMsg(DefaultFactory.getFactory().getMessages().getConnected());
	        
	      } catch (IOException ex)
	      {
	    	  m_traceEvents.add(
	    			  	TraceFactory.createExceptionTraceEvent(
	    			  			org.headlessintrace.rcp.ClientStrings.TRACE_CREATION_ERROR, 
	    			  			ex, 
	    			  			m_remoteAddress, 
	    			  			networkTracePortStr));
	      }
	      
	    } else
	    {
	      setConnectState(ConnectState.DISCONNECTED_ERR);
	    }
	}
592304
def _bind(self):
        
        if not zmq:
            return
        self.context = zmq.Context()
        self.socket = self.context.socket(zmq.PUB)
        self.socket.bind("tcp://*:%i" % self.port)
178064
function(self, socket) {
  var app = self.app,
    sid = socket.id;
  var session = self.session.get(sid);
  if (session) {
    return session;
  }

  session = self.session.create(sid, app.getServerId(), socket);
  logger.debug('[%s] getSession session is created with session id: %s', app.getServerId(), sid);

  // bind events for session
  socket.on('disconnect', session.closed.bind(session));
  socket.on('error', session.closed.bind(session));
  session.on('closed', onSessionClose.bind(null, app));
  session.on('bind', function(uid) {
    logger.debug('session on [%s] bind with uid: %s', self.app.serverId, uid);
    // update connection statistics if necessary
    if (self.connection) {
      self.connection.addLoginedUser(uid, {
        loginTime: Date.now(),
        uid: uid,
        address: socket.remoteAddress.ip + ':' + socket.remoteAddress.port
      });
    }
    self.app.event.emit(events.BIND_SESSION, session);
  });

  session.on('unbind', function(uid) {
    if (self.connection) {
      self.connection.removeLoginedUser(uid);
    }
    self.app.event.emit(events.UNBIND_SESSION, session);
  });

  return session;
}