MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_socket_bind

Function lua_socket_bind

plugins/luasocket.cpp:75–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 throw std::runtime_error(CSimpleSocket::DescribeError(err));
74}
75static 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}
96static int lua_server_accept(int id,bool fail_on_timeout)
97{
98 if(servers.count(id)==0)

Callers

nothing calls this directly

Calls 2

handle_errorFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected