当前位置: 首页>>代码示例>>C++>>正文


C++ DisconnectNamedPipe函数代码示例

本文整理汇总了C++中DisconnectNamedPipe函数的典型用法代码示例。如果您正苦于以下问题:C++ DisconnectNamedPipe函数的具体用法?C++ DisconnectNamedPipe怎么用?C++ DisconnectNamedPipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DisconnectNamedPipe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DisconnectNamedPipe

// Disconnect server or client side of the pipe.
// true - success, false - failure (use GetLastError() for more details)
bool TwoWayPipe::Disconnect()
{
    if (m_state == ServerConnected)
    {
        DisconnectNamedPipe(m_outboundPipe);
        DisconnectNamedPipe(m_inboundPipe);
        CloseHandle(m_outboundPipe);
        m_outboundPipe = INVALID_HANDLE_VALUE;
        CloseHandle(m_inboundPipe);
        m_inboundPipe = INVALID_HANDLE_VALUE;
        m_state = NotInitialized;
        return true;
    }
    else if (m_state == ClientConnected)
    {
        CloseHandle(m_outboundPipe);
        m_outboundPipe = INVALID_HANDLE_VALUE;
        CloseHandle(m_inboundPipe);
        m_inboundPipe = INVALID_HANDLE_VALUE;
        m_state = NotInitialized;
        return true;
    } 
    else 
    {
        // nothign to do
        return true;
    }
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:30,代码来源:twowaypipe.cpp

示例2: select

/* function should be able to tell if bytes are
   available and return immediately on overlapped
   asynchrounous pipes, like unix select() */
DWORD win32_fifo_read_peek(struct timeval *tv)
{
	DWORD ret = 0;
	DWORD err, timer;

	timer = (tv) ? tv -> tv_sec * 1000 : INFINITE;

	debug1("Peeking on pipe handle %p", fifohandle);

	SetLastError(0);
	if(!fifohandle) return 0;
		PeekNamedPipe(fifohandle, NULL, 0, NULL, &ret, NULL);
	err =  GetLastError();
	debug1("Waiting %ld msec for pipe to be ready", timer);
	debug1("GetLastError was %ld", err);
	if(err == ERROR_BROKEN_PIPE)
	{
		debug("Broken pipe, disconnecting");
		DisconnectNamedPipe(fifohandle);
		ConnectNamedPipe(fifohandle,&ov1);
		WaitForSingleObjectEx(fifohandle,timer,TRUE);
	}
	else if(err == ERROR_BAD_PIPE)
	{
		debug("Bad pipe, Waiting for connect");
		DisconnectNamedPipe(fifohandle);
		ConnectNamedPipe(fifohandle,&ov1);
		WaitForSingleObjectEx(fifohandle,timer,TRUE);
	}
	debug2("peek %ld bytes, error %ld",ret, err);
	return ret;
}
开发者ID:Distrotech,项目名称:mpg123,代码行数:35,代码来源:win32_support.c

示例3: main

int main() {
	HANDLE f1, f2;
	char s[128];
	DWORD x;
	
	printf("I am the server \n");

	// creating pipes
	f1=CreateNamedPipe(TEXT("\\\\.\\PIPE\\fifo1"), PIPE_ACCESS_INBOUND,PIPE_TYPE_BYTE|PIPE_WAIT, 3, 0, 0, 0, NULL);
	f2=CreateNamedPipe(TEXT("\\\\.\\PIPE\\fifo2"), PIPE_ACCESS_OUTBOUND,PIPE_TYPE_BYTE|PIPE_WAIT, 3, 0, 0, 0, NULL);
	ConnectNamedPipe(f1, NULL);
	ConnectNamedPipe(f2, NULL);
	
	// reading from pipe
	x = 0;
	if (ReadFile(f1, s, sizeof(s), &x, NULL)==0) {
		printf("reading error.. %d\n", x);
	}
	printf("read from pipe: %s\n", s);

	// writing to pipe
	strcpy(s, "Howdy!\n");
	if (WriteFile(f2, s, strlen(s)+1, &x, NULL)==0) {
		printf("writing error..%d\n", x);
	}
	
	// close pipes
	DisconnectNamedPipe(f1);
	DisconnectNamedPipe(f2);
	CloseHandle(f1);
	CloseHandle(f2);

}
开发者ID:VladutZzZ,项目名称:Labs,代码行数:33,代码来源:fifo_server.cpp

示例4: PPL_DECLARE

PPL_DECLARE (int) ppl_pipe_close (ppl_pipe_t * apipe)
{
  if (apipe == NULL)
    return -1;
  DisconnectNamedPipe (apipe->pipes[0]);
  DisconnectNamedPipe (apipe->pipes[1]);
  CloseHandle(apipe->pipes[0]);
  CloseHandle(apipe->pipes[1]);
  osip_free (apipe);
  return 0;
}
开发者ID:gozfree,项目名称:src,代码行数:11,代码来源:pplpipe.c

示例5: Sleep

void __stdcall Watcher::pipeThread(Watcher *w)
{
	for (;;) {
		HANDLE pipe = w->pipe;
		WORD rv, myv = Base::instance()->getNVersion();
		DWORD rd;
		WORD cmd;
		if (!ConnectNamedPipe(pipe, NULL)) {
			Sleep(1000);
			continue;
		}

		ReadFile(pipe, &cmd, sizeof(cmd), &rd, NULL);
		WriteFile(pipe, &myv, sizeof(myv), &rd, NULL);
		if (!cmd) {
			ReadFile(pipe, &rv, sizeof(rv), &rd, NULL);
			if (HIBYTE(rv) > HIBYTE(myv) || (HIBYTE(rv) == HIBYTE(myv) && LOBYTE(rv) > LOBYTE(myv))) {
				w->terminate();
				return;
			}
		} else {
			char file[MAX_PATH + 1];
			ReadFile(pipe, file, sizeof(file), &rd, NULL);
			file[MAX_PATH] = 0;
			log(LL_DIAG, L_NEW L_DEL L_COMMAND "%s", file);
			Sleep(6000);
			Base::instance()->forceDeleteFile(std::string(file));
		}
		
		DisconnectNamedPipe(pipe);
	}
}
开发者ID:Avalonxy,项目名称:malware-1,代码行数:32,代码来源:Watcher.cpp

示例6: FlushFileBuffers

void Channel::Destroy()
{
    if (m_creator)
    {
        FlushFileBuffers(m_pipe);
        DisconnectNamedPipe(m_pipe);
        m_creator = false;
    }

    if (m_doneEvent != INVALID_HANDLE_VALUE)
    {
        
        // Signal the done event so that if we're currently blocked reading,
        // we'll stop.

        SetEvent(m_doneEvent);

        CloseHandle(m_doneEvent);
        m_doneEvent = INVALID_HANDLE_VALUE;

    }

    if (m_readEvent != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_readEvent);
        m_readEvent = INVALID_HANDLE_VALUE;
    }

    if (m_pipe != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_pipe);
        m_pipe = INVALID_HANDLE_VALUE;
    }

}
开发者ID:feifeigd,项目名称:decoda,代码行数:35,代码来源:Channel.cpp

示例7: win_close_ptty

file_error win_close_ptty(osd_file *file)
{
	FlushFileBuffers(file->handle);
	DisconnectNamedPipe(file->handle);
	CloseHandle(file->handle);
	return FILERR_NONE;
}
开发者ID:Archlogic,项目名称:libretro-mame,代码行数:7,代码来源:winptty.c

示例8: PipeThreadMonitor

DWORD WINAPI PipeThreadMonitor(LPVOID Arg)
{
	IPCPacket packet;

	for (;;)
	{
		// Wait for the client to connect
		if (!ConnectNamedPipe(g_Pipe, nullptr))
		{
			printf("An error occurred while waiting for a client connection\n");
			return 1;
		}

		for (bool runloop = true; runloop;)
		{
			// Wait for a client message to be sent
			if (!ReadFromPipe(&packet))
			{
				printf("Failed to read from client connection\n");
				
				runloop = false;
				break;
			}

			// Handle the message here
			switch (packet.MessageType)
			{
			case VM_CLIENT_READMEM_CMD:
				VmHandleReadMem(&packet);
				break;

			case VM_CLIENT_WRITEMEM_CMD:
				VmHandleWriteMem(&packet);
				break;

			case VM_CLIENT_SHUTDOWN_CMD:
				printf("GOT A SHUTDOWN MESSAGE TYPE\n");

				// Exit the loop
				runloop = false;
				break;

			default:
				printf("GOT AN UNKNOWN MESSAGE TYPE\n");

				packet.Status = 0;
				break;
			}

			// Send the resulting packet
			if (!WriteToPipe(&packet))
				return 1;
		}

		// Disconnect the client
		DisconnectNamedPipe(g_Pipe);
	}

	return 0;
}
开发者ID:Nukem9,项目名称:VMWareClient,代码行数:60,代码来源:VmIPC.cpp

示例9: while

DWORD ChildProcess::ListenerThread()
{
	// wait for someone to connect to the pipe
	if (ConnectNamedPipe(hPipe_, NULL) || GetLastError() == ERROR_PIPE_CONNECTED)
	{
		// Acquire the lock while writing to processOutput_
		char buffer[1024];
		DWORD dwRead;
		while (ReadFile(hPipe_, buffer, sizeof(buffer) - 1, &dwRead, NULL) != FALSE)
		{
			if (dwRead > 0)
			{
				CSingleLock locker(&outputLock_);
				buffer[dwRead] = 0;
				OutputDebugStringA(buffer);
				processOutput_ += AnsiToUnicode(buffer);
			}
			SetEvent(hOutputAvailable_);
		}
	}
	else
	{
		OutputDebugString(L"Connect failed.\n");
	}

	DisconnectNamedPipe(hPipe_);

	return 0;
}
开发者ID:saluber,项目名称:UIforETW,代码行数:29,代码来源:ChildProcess.cpp

示例10: _efl_net_socket_windows_handle_close

static void
_efl_net_socket_windows_handle_close(HANDLE h)
{
   if (!FlushFileBuffers(h))
     {
        DWORD win32err = GetLastError();
        if (win32err != ERROR_PIPE_NOT_CONNECTED)
          {
             char *msg = _efl_net_windows_error_msg_get(GetLastError());
             WRN("HANDLE=%p could not flush buffers: %s", h, msg);
             free(msg);
          }
     }
   if (!DisconnectNamedPipe(h))
     {
        DWORD win32err = GetLastError();
        if ((win32err != ERROR_NOT_SUPPORTED) && /* dialer socket don't support it */
            (win32err != ERROR_PIPE_NOT_CONNECTED))
          {
             char *msg = _efl_net_windows_error_msg_get(win32err);
             WRN("HANDLE=%p could not disconnect: %s", h, msg);
             free(msg);
          }
     }
   CloseHandle(h);
   DBG("HANDLE=%p closed", h);
}
开发者ID:tasn,项目名称:efl,代码行数:27,代码来源:efl_net_socket_windows.c

示例11: fcgi_close

static inline void fcgi_close(fcgi_request *req, int force, int destroy)
{
    if (destroy) {
        zend_hash_destroy(&req->env);
    }

#ifdef _WIN32
    if (is_impersonate) {
        RevertToSelf();
    }
#endif

    if ((force || !req->keep) && req->fd >= 0) {
#ifdef _WIN32
        HANDLE pipe = (HANDLE)_get_osfhandle(req->fd);

        if (!force) {
            FlushFileBuffers(pipe);
        }
        DisconnectNamedPipe(pipe);
#else
        if (!force) {
            char buf[8];

            shutdown(req->fd, 1);
            while (recv(req->fd, buf, sizeof(buf), 0) > 0) {}
        }
        close(req->fd);
#endif
        req->fd = -1;
    }
}
开发者ID:hsomesun,项目名称:dezend,代码行数:32,代码来源:fastcgi.c

示例12: DisconnectNamedPipe

void CPipeBase::ClosePipe()
{
    if (m_hPipeClient != INVALID_HANDLE_VALUE)
    {
		DisconnectNamedPipe( m_hPipeClient );
        CloseHandle(m_hPipeClient);
        m_hPipeClient = INVALID_HANDLE_VALUE;
    }

	if (m_hPipeServer != INVALID_HANDLE_VALUE)
    {
		DisconnectNamedPipe( m_hPipeServer );
        CloseHandle(m_hPipeServer);
        m_hPipeServer = INVALID_HANDLE_VALUE;
    }
}
开发者ID:MakotoTaniguchi,项目名称:ProxyCmd,代码行数:16,代码来源:PipeBase.cpp

示例13: DisconnectNamedPipe

bool MWinNamedPipeServer::Connect(void)
	{
	if(mClientConnected==true)
		{
		DisconnectNamedPipe(mhPipe);
		}

	if(ConnectNamedPipe(mhPipe,NULL)==FALSE)
		{
		// It is possible that a client connects before the ConnectNamedPipe is invoked after CreateNamed Pipe.
		// Connections is still good! 
		//  Ref: https://msdn.microsoft.com/query/dev15.query?appId=Dev15IDEF1&l=EN-US&k=k(NAMEDPIPEAPI%2FConnectNamedPipe);k(ConnectNamedPipe);k(DevLang-C%2B%2B);k(TargetOS-Windows)&rd=true
		DWORD error=GetLastError();
		if(error==ERROR_PIPE_CONNECTED)
			{
			mClientConnected=true;
			return true;
			}

		mClientConnected=false;
		return false;
		}

	mClientConnected=true;
	return true;
	}
开发者ID:profdevi,项目名称:MPipeServer,代码行数:26,代码来源:MWinNamedPipe.cpp

示例14: rpcrt4_conn_listen_pipe

static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
{
  if (npc->listening)
    return RPC_S_OK;

  npc->listening = TRUE;
  for (;;)
  {
      if (ConnectNamedPipe(npc->pipe, &npc->ovl))
          return RPC_S_OK;

      switch(GetLastError())
      {
      case ERROR_PIPE_CONNECTED:
          SetEvent(npc->ovl.hEvent);
          return RPC_S_OK;
      case ERROR_IO_PENDING:
          /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
          return RPC_S_OK;
      case ERROR_NO_DATA_DETECTED:
          /* client has disconnected, retry */
          DisconnectNamedPipe( npc->pipe );
          break;
      default:
          npc->listening = FALSE;
          WARN("Couldn't ConnectNamedPipe (error was %d)\n", GetLastError());
          return RPC_S_OUT_OF_RESOURCES;
      }
  }
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:30,代码来源:rpc_transport.c

示例15: close_client_connection

static void close_client_connection(NVQRConnection c)
{
#if defined (_WIN32)
    DisconnectNamedPipe(c.client_handle);
#else
#endif
}
开发者ID:NVIDIA,项目名称:nvidia-query-resource-opengl,代码行数:7,代码来源:nvidia-query-resource-opengl.c


注:本文中的DisconnectNamedPipe函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。