Im not sure i have understood ya correctly - "Event-driven" u mean one action at a time?
Current code looks like this:
Class:Code:void CtestDlg::TorManage(void) { errorss =socket_tor.Create(2555,SOCK_STREAM,FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); errorss = socket_tor.Connect(_T("localhost"),9051); errorss = GetLastError(); } void CtestDlg::OnBnClickedButtonTor() { TorManage(); } void CtestDlg::OnBnClickedButton1() { errorss =socket_tor.SendTo("authenticate \"h\"",strlen("authenticate \"h\""),2555,_T("127.0.0.1"),MSG_OOB); } void CtestDlg::OnBnClickedButton2() { //AfxMessageBox((LPCTSTR) (errorss)); socket_tor.ShutDown(2); socket_tor.Close(); }
Returned values:Code:class CSockety : public CAsyncSocket { public: //void SetParentDlg(CDialog *pDlg); virtual void OnAccept(int nErrorCode){}; virtual void OnClose(int nErrorCode){}; virtual void OnConnect(int nErrorCode){}; virtual void OnOutOfBandData(int nErrorCode){}; virtual void OnReceive(int nErrorCode){}; virtual void OnSend(int nErrorCode){this->SendTo("authenticate \"h\"",strlen("authenticate \"h\""),MSG_OOB);}; };
OnClose isnt called when im closing connection is it normal?Code:errorss =socket_tor.Create(2555,SOCK_STREAM,FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); //errors=1 after calling errorss = socket_tor.Connect(_T("localhost"),9051); //errors = 10035- correctly, then it calls OnConnect i OnSend, so it means that my connection was estabilished ( on port 9051, localhost)? errorss =socket_tor.SendTo("getconf maxci",strlen("getconf maxci"),2555,_T("127.0.0.1"),MSG_OOB); // errors = 13 - correctly, 13 bits were sent. BUT: OnSend, wasnt called this time same happens if i put Send instead of SendTo here.
CAsyncSocket::SetSockOpt does it have something to do with my problem? Control Protocol seems to be secured so any non-authenticate msg kills my socket connection with the server.
Screens from Debugging:
http://snpr.cm/0baJL4.jpg
http://snpr.cm/E2cTG0.jpg
http://snpr.cm/jkSZ02.jpg
http://snpr.cm/00w3yt.jpg
http://snpr.cm/MeKRAf.jpg
--------------------------------------------------
Everything works now the problem was in incomplete msg It required \r\n at the endThanks and good luck
![]()




Thanks and good luck
Reply With Quote