Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qfmclient
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuai.liu
qfmclient
Commits
886fbb67
Commit
886fbb67
authored
Dec 06, 2017
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 捕获退出消息,正确停止线程,进行清理工作
2. 修改socket属性设置SO_RESUEADDR
parent
d0ebe816
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
11 deletions
+41
-11
bin/store_info.ini
+1
-1
common.h
+0
-0
main.cpp
+22
-0
qfmclient.cpp
+16
-10
qfmclient.h
+2
-0
No files found.
bin/store_info.ini
View file @
886fbb67
...
...
@@ -3,4 +3,4 @@ partner_id=1371
store_id
=
fm99999
pos_id
=
1
operator_id
=
001
business_date
=
20171
016
business_date
=
20171
205
common.h
View file @
886fbb67
main.cpp
View file @
886fbb67
...
...
@@ -4,14 +4,36 @@
//不显示控制台
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
BOOL
WINAPI
HandlerRoutine
(
_In_
DWORD
dwCtrlType
);
QFmClient
*
pFm
=
nullptr
;
int
main
(
int
argc
,
char
*
argv
[])
{
QCoreApplication
a
(
argc
,
argv
);
SetConsoleCtrlHandler
(
HandlerRoutine
,
TRUE
);
InitLogger
();
QLOG_INFO
()
<<
"start client..."
;
QFmClient
client
;
pFm
=
&
client
;
client
.
start
();
return
a
.
exec
();
}
BOOL
WINAPI
HandlerRoutine
(
_In_
DWORD
dwCtrlType
)
{
switch
(
dwCtrlType
)
{
// Handle the CTRL + C signal.
case
CTRL_C_EVENT
:
case
CTRL_CLOSE_EVENT
:
OutputDebugStringA
(
"quit client...
\n
"
);
pFm
->
CloseSock
();
pFm
->
wait
();
QLOG_INFO
()
<<
"quit client...
\n\n\n\n
"
;
break
;
// CTRL-CLOSE: confirm that the user wants to exit.
default:
break
;
}
return
FALSE
;
}
qfmclient.cpp
View file @
886fbb67
...
...
@@ -40,6 +40,11 @@ QFmClient::QFmClient(QObject *parent) : QThread(parent),store_info("1371","fm999
_endflag
=
false
;
}
QFmClient
::~
QFmClient
()
{
OutputDebugStringA
(
"~QFmClient()"
);
}
bool
QFmClient
::
Init
(
QString
proxy_IP
,
unsigned
short
proxy_port
,
unsigned
short
listen_prot
,
unsigned
short
long_timeout
,
unsigned
short
short_timeout
)
{
...
...
@@ -116,6 +121,14 @@ bool QFmClient::InitStoreInfo()
return
true
;
}
void
QFmClient
::
CloseSock
()
{
_endflag
=
true
;
closesocket
(
_listenSock
);
requestInterruption
();
OutputDebugStringA
(
"close listen socket"
);
}
int
QFmClient
::
RecvSockData
(
int
sock
,
char
*
buffer
,
int
length
)
{
#ifdef WIN32
...
...
@@ -976,15 +989,6 @@ void QFmClient::run()
}
}
CloseSocket
(
&
_zhProxySock
);
// if (0 != rlt)
// {
// if (nResult == FREEMUD_PAY)
// {
// //is write off data, need to check roll back
// BackupPosReq(temp_recv);
// break;
// }
// }
CloseSocket
(
&
_acceptedSock
);
}
while
(
1
);
if
(
bBackup
)
...
...
@@ -993,10 +997,12 @@ void QFmClient::run()
QLOG_INFO
()
<<
"backup:
\n
"
<<
_sendbuf
;
bBackup
=
false
;
}
if
(
_endflag
)
WaitAndSleep
(
3000
);
}
while
(
!
_endflag
);
}
while
(
!
isInterruptionRequested
()
);
qDebug
()
<<
"Exit ZH Client!
\r\n
"
;
QLOG_INFO
()
<<
"Exit ZH Client!
\r\n
"
;
#ifdef WIN32
WSACleanup
();
...
...
qfmclient.h
View file @
886fbb67
...
...
@@ -23,9 +23,11 @@ class QFmClient : public QThread
Q_OBJECT
public
:
QFmClient
(
QObject
*
parent
=
NULL
);
~
QFmClient
();
void
run
();
bool
Init
(
QString
proxy_IP
,
unsigned
short
proxy_port
,
unsigned
short
listen_prot
,
unsigned
short
long_timeout
,
unsigned
short
short_timeout
);
bool
InitStoreInfo
();
void
CloseSock
();
signals
:
void
Error
(
QString
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment