connected udp (xtcp module)

Technical questions regarding the XTC tools and programming with XMOS.
mikhail
Junior Member
Posts: 7
Joined: Fri Jul 30, 2010 12:16 pm

connected udp (xtcp module)

Post by mikhail »

Hello,

could anyone please help me with udp streaming in xtcp module. I want to generate udp stream. The problem is that I first have to receive a message from the receiver side so that my program XTCP_SENT_DATA event becomes. Only then I can gererate my udp packets (which are rtp packets). Here is the code:

Code: Select all

  
  xtcp_connect(tcp_svr, rem_port, host, XTCP_PROTOCOL_UDP);
  xtcp_set_poll_interval(tcp_svr, conn, 1);
  xtcp_ask_for_event(tcp_svr);
  while(1) {
    select {
      case xtcp_event(tcp_svr, conn):
				switch (conn.event) {
					case XTCP_NEW_CONNECTION:
						httpd_init_state(tcp_svr, conn);
						xtcp_init_send(tcp_svr, conn);
						break;
					case XTCP_RECV_DATA:
					  len = xtcp_recv(tcp_svr, data);
						break;
					case XTCP_REQUEST_DATA:
					case XTCP_RESEND_DATA:
						xtcp_send(tcp_svr, data, PAYLOAD_LEN);
						break;
					case XTCP_SENT_DATA:
						tmr :> t;	/* save the current timer value */
						if (send_rtp_audio (tcp_svr)) {
							return;
						}
						tmr when timerafter(t + DELAY) :> void;        /* wait till the send period is over */
						break;
					case XTCP_TIMED_OUT:
					case XTCP_ABORTED:
					case XTCP_CLOSED:
						httpd_free_state(conn);
						break;
				}
        xtcp_ask_for_event(tcp_svr);
        break;
      }
  }

The xtcp server work flow is as follows:
xtcp_connect - creates kind of the socket
generates XTCP_NEW_CONNECTION event
generates XTCP_REQUEST_DATA event
the receiver side has to send any message
generates XTCP_RECV_DATA event
generates XTCP_SEND_DATA event

All I want is just to have this:
xtcp_connect - creates kind of the socket
generates XTCP_NEW_CONNECTION event
generates XTCP_SEND_DATA event

Is it possibe with xtcp or uip stacks?


User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

I think the uIP stack can do that no problem, its just the xtcp thing that xmos put on top thats usually in the way. You can try looking in to the documentation for uIP and see if you want modify the code to make it work.