| 73 | throw std::runtime_error(CSimpleSocket::DescribeError(err)); |
| 74 | } |
| 75 | static int lua_socket_bind(std::string ip,int port) |
| 76 | { |
| 77 | static int server_id=0; |
| 78 | CPassiveSocket* sock=new CPassiveSocket; |
| 79 | if(!sock->Initialize()) |
| 80 | { |
| 81 | CSimpleSocket::CSocketError err=sock->GetSocketError(); |
| 82 | delete sock; |
| 83 | handle_error(err,false); |
| 84 | } |
| 85 | sock->SetBlocking(); |
| 86 | if(!sock->Listen(ip.c_str(),port)) |
| 87 | { |
| 88 | handle_error(sock->GetSocketError(),false); |
| 89 | } |
| 90 | server_id++; |
| 91 | server& cur_server=servers[server_id]; |
| 92 | cur_server.socket=sock; |
| 93 | cur_server.last_client_id=0; |
| 94 | return server_id; |
| 95 | } |
| 96 | static int lua_server_accept(int id,bool fail_on_timeout) |
| 97 | { |
| 98 | if(servers.count(id)==0) |
nothing calls this directly
no test coverage detected