CSocket.accept Method |
Namespace: VO
1FUNCTION ServerTest() 2LOCAL oSocket AS CSocket 3LOCAL oSockMsg AS CSocket 4LOCAL cData AS STRING 5LOCAL cFrom AS STRING 6LOCAL nPort AS INT 7LOCAL lRet AS LOGIC 8oSocket := CSocket{SOCK_STREAM} 9IF oSocket:bind(7, NULL_STRING, AF_INET) 10oSocket:listen(1) 11lRet := .F. 12oSockMsg := oSocket:accept() 13IF oSockMsg != NULL_OBJECT 14cData := oSockMsg:GetLine() 15oSockMsg:getpeername(@cFrom, @nPort) 16? "Connection accepted from ", cFrom, ; 17, client port: , NTrim(nPort) 18? "Received data: ", cData 19lRet := .T. 20ENDIF 21oSockMsg:Close() 22ENDIF 23oSocket:Close() 24RETURN lRet