rtai3.3 - rtdm- rt_dev_socket

Djamel Louar djamel.louar at inria.fr
Fri Jun 9 11:53:15 CEST 2006


hello,

    I'm a beginner in rtai , I do a little program to create a socket 
with the function rt_dev_socket() , but the result of  this function is 
negative .
I don 't  know where is the problem.  Could you  tell me  what  i should 
do .

this my program :    rtdm_soc.c
 
#include <rtai_lxrt.h>
#include <rtai_sem.h>
#include <rtai_shm.h>
#include <rtdm/rtdm.h>
#include <netinet/in.h> /* for internet sockets */

static RT_TASK *maint;

 int main(int argc, char* argv[]) {
 
   int sd=89;
  struct sockaddr_in saddr; /* socket address */
 
  if(!(maint=rt_task_init_schmod(nam2num("MAINT"),1,0,0,SCHED_FIFO, 0xF)))
    printf("Cannot init main task \n");
  mlockall(MCL_CURRENT | MCL_FUTURE);

  rt_set_oneshot_mode();
  start_rt_timer(0);


sd =rt_dev_socket(PF_INET,SOCK_DGRAM,0);
  printf("sd:%d\n",sd);



  rt_task_delete(maint);
  return 0;
 }



and my makefile :

TARGET= rtdm_soc

RTAIDIR=/usr/realtime
RTAI_LIB_DIR=$(shell rtai-config --library-dir)
CC= gcc
CFLAGS = -g -I $(RTAIDIR)/include -lpthread -llxrt -lrtdm -L 
$(RTAI_LIB_DIR) -Wall -O2

all: $(TARGET)

$(TARGET): $(TARGET).c

clean:
    $(RM) $(TARGET)


after loading modules and execute :

cd /usr/realtime/modules/

  insmod ./rtai_hal.ko
  insmod ./rtai_lxrt.ko
  insmod ./rtai_shm.ko
  insmod ./rtai_sem.ko
  insmod ./rtai_rtdm.ko 

./rtdm_soc

------------
the result is:

sd=-97


thanks for your help








More information about the Rtai mailing list