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


C++ ConnectionManager::ShutdownConnection方法代码示例

本文整理汇总了C++中ConnectionManager::ShutdownConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionManager::ShutdownConnection方法的具体用法?C++ ConnectionManager::ShutdownConnection怎么用?C++ ConnectionManager::ShutdownConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionManager的用法示例。


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

示例1: main

int main(int argc, char *argv[])
{
  ConnectionManager connection;
  SOCKET connect_socket = connection.CreateClientConnection();

  #pragma region WYSYLANIE

  #define DEFAULT_BUFLEN 512

  int recvbuflen = DEFAULT_BUFLEN;

  char *sendbuf = new char[DEFAULT_BUFLEN];
  char recvbuf[DEFAULT_BUFLEN];

  int result = 0;

  do {
  printf("Wiadomosc do wyslania: \n");
  scanf("%s", sendbuf);
  //printf("Wiadomosc jaka wysle: %s\n", sendbuf);

  if (strcmp(sendbuf, "quit") == 0) break;
  // Send an initial buffer
  result = send(connect_socket, sendbuf, static_cast<int>(strlen(sendbuf)), 0);
  if (result == SOCKET_ERROR) {
  printf("send failed: %d\n", WSAGetLastError());
  closesocket(connect_socket);
  WSACleanup();
  //
  getch();
  //
  return 1;
  }
  } while (true);

  #pragma endregion blok odpowiedzialny za komunikacje z serwerem

  connection.ShutdownConnection(connect_socket);

	printf("Client exit.\n");
	getch();
	return 0;
}
开发者ID:krodzik,项目名称:MyFTP,代码行数:43,代码来源:Client.cpp

示例2: main

int main(int argc, char *argv[])
{
  ConnectionManager connection;
  SOCKET listen_socket = connection.CreateServerConnection();
  SOCKET client_socket;
  
  ProcessesAndThreadsManager process_manager;

  while (client_socket = connection.AcceptingConnection(listen_socket)) {

    // in there should be process_manager.SetPathToProcess function
    char *sciezka = new char[256];
    strcpy(sciezka, "F:\\dropbox\\myftp\\MyFTP - ClientsManager\\ClientsManager\\debug\\ClientsManager");
    strcat(sciezka, " ");
    // copy socket handle to argument list of new process
    char str_to_socket[10];
    itoa(client_socket, str_to_socket, 10);
    strcat(sciezka, str_to_socket);
    printf("Sciezka do procesu tuz przed wyslaniem:\n%s\n", sciezka);
    USES_CONVERSION;
    TCHAR* dziecko = A2T(sciezka);
    process_manager.path_to_process_ = dziecko;

    process_manager.CreateNewProcess();

  }

  process_manager.WaitForProcessToEnd();
  process_manager.CloseHandles();
  printf("Client disconnect.\n");

  connection.ShutdownConnection(client_socket);
  closesocket(listen_socket);

	printf("Server exit.\n");
	return 0;
}
开发者ID:krodzik,项目名称:MyFTP,代码行数:37,代码来源:server.cpp


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