本文整理汇总了C++中ACE_SOCK_Stream::close_reader方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_SOCK_Stream::close_reader方法的具体用法?C++ ACE_SOCK_Stream::close_reader怎么用?C++ ACE_SOCK_Stream::close_reader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_SOCK_Stream
的用法示例。
在下文中一共展示了ACE_SOCK_Stream::close_reader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static ACE_THR_FUNC_RETURN
process(void* arg){
ACE_INET_Addr addr;
ACE_SOCK_Stream stream;
ACE_HANDLE handle = (ACE_HANDLE) (intptr_t) arg;
stream.set_handle(handle);
/*make sure we're not in non-blocking mode.*/
if(stream.disable(ACE_NONBLOCK) == -1){
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"disable"),
0);
}
else if(stream.get_remote_addr(addr) == -1){
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_remote_addr"),
0);
}
ACE_DEBUG ((LM_INFO,
"(%P|%t:%l) client %s connected from %d\n",
addr.get_host_name (),
addr.get_port_number ()));
int r_bytes = 0;
char buf[SIZE];
ACE_CString cs;
do{
r_bytes = stream.recv(buf, SIZE);
if(r_bytes == 0 || r_bytes == -1){
ACE_DEBUG((LM_INFO,
"(%P|%t:%l) r_bytes = %d, exit from the loop\n", r_bytes));
break;
}
for(int i=0; i< r_bytes; i++){
cs += buf[i];
}
}while(true);
stream.close_reader();
/*
ACE_DEBUG((LM_INFO,
"%s\n", cs.c_str()));
*/
/*the layout of the message would be:
* ^^pq||step1$$
* 1st step: get the d by pq
* 2nd calculate
* 3rd send back the digest
*/
int p0, p1;
int len = cs.length();
p0 = 2;
p1 = cs.find("||");
ACE_CString pq = cs.substr(2, p1 - 2);
ACE_CString step1 = cs.substr(p1 + 2, len - p1 -4);
/*
ACE_DEBUG((LM_INFO,
"pq = %s\n step1 = %s\n", pq.c_str(), step1.c_str()));
*/
//get the d
ACE_CString sql = "select d,textid from player0 where pq='";
sql += pq;
sql += "'";
/*
ACE_DEBUG((LM_INFO,
"sql = %s\n", sql.c_str()));
*/
PGconn* con;
con = PQconnectdb("host=45.33.3.188 port=5432 dbname=nv user=dec");
PGresult* res;
if(PQstatus(con)!= CONNECTION_OK){
ACE_DEBUG((LM_INFO,
"Connection to database failed:%s\n",
PQerrorMessage(con)));
reclaim_conn(con);
}
res = PQexec(con, sql.c_str());
int n = PQntuples(res);
if(n != 1){
ACE_ERROR((LM_ERROR,
"there is significant error: %d\n", n));
// return 0;
}
ACE_CString d = "";
d += PQgetvalue(res, 0, 0);
/*
ACE_DEBUG((LM_INFO,
"d = %s\n", d.c_str()));
*/
bn* pq_ = from_hex(&pq);
bn* d_ = from_hex(&d);
bn* step1_ = from_hex(&step1);
bn* step2_ = npmod(step1_ , d_ , pq_ );
ACE_CString* step2 = step2_->to_hex();
//check if the pq is taking the ownnership?
/* if pq is 'centralbank', bypass the check, otherwise check the payer whether has the ownnership of the note;
* select count(*) from ownership0 o, player0 p where o.owner = p.textid and o.note='0x12345678' and p.pq='0x12345678';
//.........这里部分代码省略.........