示例#1
0
int32_t send_packet(struct connection *c,wpacket_t w)
{
    if(!test_sendable(c->status)){
		wpk_destroy(&w);
		return -1;
	}
	st_io *O;
	if(w){
		w->base.tstamp = GetSystemMs64();
        LLIST_PUSH_BACK(&c->send_list,w);
	}
	if(!c->doing_send){
	    c->doing_send = 1;
		O = prepare_send(c);
		if(O) return Post_Send(c->socket,O);
	}
	return 0;
}
示例#2
0
int32_t connection_send(struct connection *c,wpacket_t w,packet_send_finish callback)
{
	st_io *O;
	if(w)
	{
		w->send_tick = GetCurrentMs();
		w->_packet_send_finish = callback;
		LINK_LIST_PUSH_BACK(c->send_list,w);
	}
	if(!c->send_overlap.isUsed)
	{
		O = prepare_send(c);
		if(O)
		{
			c->send_overlap.isUsed = 1;	
			return Post_Send(c->socket,O);
		}
	}
	return 0;
}