Beispiel #1
0
void
Acceptor::connectionAccepted(
    int fd, const TSocketAddress& clientAddr) noexcept {
  if (!canAccept(clientAddr)) {
    close(fd);
    return;
  }
  auto acceptTime = getCurrentTime();
    TransportInfo tinfo;
    tinfo.acceptTime = acceptTime;
    TAsyncSocket::UniquePtr sock(new TAsyncSocket(base_, fd));
    connectionReady(std::move(sock), clientAddr, empty_string, tinfo);
  }
Beispiel #2
0
void
Acceptor::connectionAccepted(
    int fd, const SocketAddress& clientAddr) noexcept {
  if (!canAccept(clientAddr)) {
    close(fd);
    return;
  }
  auto acceptTime = std::chrono::steady_clock::now();
  for (const auto& opt: socketOptions_) {
    opt.first.apply(fd, opt.second);
  }

  onDoneAcceptingConnection(fd, clientAddr, acceptTime);
}
/* Initializes the class by opening 2 can channels at the given
 * frequency, which should be one of the #defined BAUD_*K values
 *
 * returns: 0 on success, negative on error
 */
int
CANIOKvaser::Init(long channel_freq)
{
	int ret;

	// Open up both CAN channels

	for (int i =0; i < DUALCAN_NR_CHANNELS; i++)
	{
		if((channels[i] =
			canOpenChannel(i, canWANT_EXCLUSIVE | canWANT_EXTENDED)) < 0) {
			return channels[i];
		}

		// set the channel params: 500Kbps ... CANLIB will set the other params
		// to defaults if we use BAUD_500K
		//    if ((ret = canSetBusParams(channels[i], channel_freq, 4, 3, 1, 1, 0)) < 0) {
		if ((ret = canSetBusParams(channels[i], channel_freq, 0, 0, 0, 0, 0)) < 0)
			return ret;

		// set filter to only accept packets we are interested in...
		// that is, messages with IDs 0x400, 0x401, ..., 0x404
		if ((ret = canAccept(channels[i], 0x400, canFILTER_SET_MASK_STD)) < 0) {
			return ret;
		}

		if ((ret = canAccept(channels[i], 0x400, canFILTER_SET_CODE_STD)) < 0) {
			return ret;
		}

		// turn on the bus!
		if ((ret = canBusOn(channels[i])) < 0)
			return ret;
	}

	return 0;
}
Beispiel #4
0
void
Acceptor::connectionAccepted(
    int fd, const SocketAddress& clientAddr) noexcept {
  if (!canAccept(clientAddr)) {
    // Send a RST to free kernel memory faster
    struct linger optLinger = {1, 0};
    ::setsockopt(fd, SOL_SOCKET, SO_LINGER, &optLinger, sizeof(optLinger));
    close(fd);
    return;
  }
  auto acceptTime = std::chrono::steady_clock::now();
  for (const auto& opt: socketOptions_) {
    opt.first.apply(fd, opt.second);
  }

  onDoneAcceptingConnection(fd, clientAddr, acceptTime);
}
void KeywordDialog::acceptButtonClicked()
{
    if (canAccept())
        accept();
}