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

Function lua_socket_connect

plugins/luasocket.cpp:231–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229 }
230}
231static int lua_socket_connect(std::string ip,int port)
232{
233 static int last_client_id=0;
234 CActiveSocket* sock=new CActiveSocket;
235 if(!sock->Initialize())
236 {
237 CSimpleSocket::CSocketError err=sock->GetSocketError();
238 delete sock;
239 throw std::runtime_error(CSimpleSocket::DescribeError(err));
240 }
241 if(!sock->Open(ip.c_str(),port))
242 {
243 CSimpleSocket::CSocketError err=sock->GetSocketError();
244 delete sock;
245 throw std::runtime_error(CSimpleSocket::DescribeError(err));
246 }
247 sock->SetNonblocking();
248 last_client_id++;
249 clients[last_client_id]=sock;
250 return last_client_id;
251}
252CSimpleSocket* get_socket(int server_id, int client_id)
253{
254 std::map<int, CActiveSocket*>* target = &clients;

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.80
OpenMethod · 0.45

Tested by

no test coverage detected