int
socket_send(int ser_id, char *message, int len)
{
   struct tcb *ptcb = NULL;
   struct rte_mbuf *mbuf = get_mbuf();
   ptcb = get_tcb_by_identifier(ser_id);
   sendtcpdata(ptcb, mbuf, message, len);
  // sendtcppacket(ptcb, mbuf, message, len);
  // ptcb->send_data(message, len); 
}
int
check_socket_out_queue(void)
{
   Socket_Send_Msg *msg;
   uint32_t i;
   unsigned char message[1500];
   struct tcb *ptcb = NULL;
   struct tcb *temp = NULL;
   pthread_mutex_lock(&tcb_alloc_mutex);
   uint32_t TotalTcbs = Ntcb;
   pthread_mutex_unlock(&tcb_alloc_mutex);
    
   for(i=0; i<TotalTcbs; i++) {  // change it to hash type later
   //   if( i != 0)
      //printf("Checking tcb %d for sendingi %d %d\n", i, Ntcb, TotalTcbs);
      ptcb = tcbs[i];
      if(ptcb == NULL) {
         continue;
      }
      int num = rte_ring_dequeue(ptcb->tcb_socket_ring_recv, (void **)&msg);
      if(num < 0) {
         if(ptcb->need_ack_now) {
            logger(LOG_TCP, LOG_LEVEL_NORMAL, "sending immidiate ack for tcb %u\n", ptcb->identifier);
            ptcb->tcp_flags = TCP_FLAG_ACK;
            sendtcpdata(ptcb, NULL, 0);
            ptcb->need_ack_now = 0;
            // will use a saeparate api for ack later.
         }
         continue;
      }
      if(msg->m_Msg_Type == SOCKET_CLOSE) {
         temp = get_tcb_by_identifier(msg->m_Identifier);
         if(temp != ptcb) {
            printf ("Everything screewed at tcb'\n");
            exit(0);
      // put assert
         }
         ptcb->tcp_flags = TCP_FLAG_ACK | TCP_FLAG_FIN; // no problem in acking
         ptcb->need_ack_now = 1;
    //     sendfin(ptcb);
      }
      if(msg->m_Msg_Type == CONNECTION_OPEN) {
         temp = get_tcb_by_identifier(msg->m_Identifier);
         if(temp != ptcb) {
            printf ("Everything screewed at tcb'\n");
            exit(0);
      // put assert
         }
         sendsyn(ptcb);
         ptcb->state = SYN_SENT; 
      }
      if(msg->m_Msg_Type == SEND_DATA) {
         printf("****** Received %s and len %d and identifier %d\n",(char *)msg->m_Data, msg->m_Len, msg->m_Identifier);
         memcpy(message, msg->m_Data, msg->m_Len);
     
         temp = get_tcb_by_identifier(msg->m_Identifier);
         if(temp != ptcb) {
            printf ("Everything screewed at tcb'\n");
            exit(0);
      // put assert
         }
         ptcb->tcp_flags = TCP_FLAG_ACK; 
         sendtcpdata(ptcb, message, msg->m_Len);
      }
      rte_mempool_put(buffer_message_pool, msg);
   }
   return 0;
}