Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. bool RunServer(int portNumber)
  2. {
  3.     SOCKET hSocket = INVALID_SOCKET, hClientSocket = INVALID_SOCKET;
  4.     bool bSuccess = true;
  5.     sockaddr_in sockAddr = {0};
  6.     try {
  7.         // Создаем socket
  8.         cout << "Creating socket... ";
  9.         if ((hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
  10.         throw ROTException("could not create socket.");
  11.         cout << "created.\n";
  12.         // Связывае
  13.         socket cout << "Binding socket... ";
  14.         SetServerSockAddr(&sockAddr, portNumber);
  15.         if (bind(hSocket, reinterpret_cast(&sockAddr), sizeof(sockAddr))!=0)
  16.         throw ROTException("could not bind socket."); cout << "bound.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement