MCPcopy Create free account
hub / github.com/anjo76/angelscript / Accept

Method Accept

sdk/add_on/scriptsocket/scriptsocket.cpp:136–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136CScriptSocket* CScriptSocket::Accept(asINT64 timeoutMicrosec)
137{
138 // Cannot accept a client on an ordinary socket or if the socket is not active
139 if (!m_isListening || m_socket == -1)
140 return 0;
141
142 // First determine if there is anything to receive so that doesn't block
143 int r = Select(timeoutMicrosec);
144 if (r <= 0)
145 return 0;
146
147 // TODO: need to be able to check to what ip address and port the socket is connected it (use getsockopt with SO_BSP_STATE)
148 // For each incoming client connection a new CScriptSocket is created
149 int clientSocket = (int)accept(m_socket, 0, 0);
150 if (clientSocket != -1)
151 {
152 CScriptSocket* client = new CScriptSocket();
153 client->m_socket = clientSocket;
154 return client;
155 }
156
157 return 0;
158}
159
160int CScriptSocket::Close()
161{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected