Sorry for the previous unexpected line wrap... this time hopefully this will work... please note that I am trying to communicate periodically with an application running standard winsock UDP/IP socket on windows machine....Please rectify if I have made any fundamental error...
The source code... static struct sockaddr_in local_addr; static struct sockaddr_in server_addr; static void *SendRcvFun(void *arg) { RT_TASK *handler; //local handler static struct { unsigned long indx; RTIME time; } msg = {0,0}; int sockfd = 0; int ret = 0; char msgStr[100] = "Hello world"; /* Set variables to zero. */ memset(msgStr, 0, sizeof(msgStr)); memset(&local_addr, 0, sizeof (struct sockaddr_in)); memset(&server_addr, 0, sizeof(struct sockaddr_in)); printf("RTnet, simpleserver for LXRT\n"); /* Check arguments and set addresses. */ local_addr.sin_family = AF_INET; local_addr.sin_addr.s_addr = INADDR_ANY; local_addr.sin_port = htons(11000);//htons(atoi(11000)); server_addr.sin_family = AF_INET; inet_aton("139.30.6.66", &server_addr.sin_addr); server_addr.sin_port = htons(11000); printf("SendRcv Start\n"); rtf_create(FIFO, 2000); printf("FIFO created\n"); mlockall(MCL_CURRENT | MCL_FUTURE); sockfd = rt_dev_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sockfd < 0) { printf("Error opening socket: %d\n", sockfd); exit(1); } // if (!(handler= rt_task_init_schmod(nam2num("SRTSK"), 0, 0, 0,SCHED_FIFO, 0xFF))) { printf("CANNOT INIT SendRcvFun\n"); rt_dev_close(sockfd); exit(1); } rt_set_periodic_mode(); start_rt_timer(0); period = start_rt_timer(nano2count(TIMERTICKS)); rt_task_make_periodic(handler, rt_get_time()+period, period); rt_make_hard_real_time(); /* Bind socket to local address specified as parameter. */ ret = rt_dev_bind(sockfd, (struct sockaddr *) &local_addr, sizeof(struct sockaddr_in)); /* Specify destination address for socket; needed for rt_socket_send(). */ rt_dev_connect(sockfd, (struct sockaddr *) &server_addr, sizeof(struct sockaddr_in)); endSendRcvFun = 0; while (!endSendRcvFun) { ret = rt_dev_recv(sockfd, msgStr, sizeof(msgStr), MSG_DONTWAIT); ret = rt_dev_send(sockfd, msgStr, sizeof(msgStr), MSG_DONTWAIT); msg.indx = ret; msg.time = rt_get_time_ns(); rtf_put(FIFO, &msg, sizeof(msg)); //printk("h"); rt_task_wait_period(); } stop_rt_timer(); rt_make_soft_real_time(); rt_dev_close(sockfd); rt_task_delete(handler); rtf_destroy(FIFO); return 0; } I suspect the error occurs when I insert the code ret = rt_dev_recv(sockfd, msgStr, sizeof(msgStr), MSG_DONTWAIT); The error reported by the dmesg... *** RTnet 0.9.8 - built on Jan 12 2007 20:25:45 *** RTnet: initialising real-time networking initializing loopback... RTnet: registered rtlo ACPI: PCI Interrupt 0000:02:08.0[A] -> Link [LNKD] -> GSI 9 (level, low) -> IRQ 9 rteth0: OEM i82557/i82558 10/100 Ethernet, 00:30:05:08:51:74, IRQ 9. RTnet: registered rteth0 RTnet: host 222.83.167.242 unreachable RTnet: no protocol found RTnet: no protocol found RTnet: no protocol found RTnet: no protocol found LXRT CHANGED MODE (TRAP), PID = 4313, VEC = 14, SIGNO = 11. BUG: unable to handle kernel NULL pointer dereference at virtual address 00000024 printing eip: d0f666be *pde = 00000000 Oops: 0000 [#1] PREEMPT Modules linked in: rt_eepro100 rt_loopback rtipv4 rtnet rtai_rtdm rtai_fifos rtai_sem rtai_lxrt rtai_hal button battery ac loop dm_mod bttv video_buf firmware_class ir_common compat_ioctl32 i2c_algo_bit v4l2_common btcx_risc tveeprom videodev mii intel_agp agpgart ide_cd uhci_hcd cdrom usbcore i8xx_tco i2c_i801 shpchp i2c_core pci_hotplug parport_pc lp parport ext3 mbcache jbd edd fan sg aic7xxx scsi_transport_spi piix thermal processor sd_mod scsi_mod ide_disk ide_core CPU: 0 EIP: 0060:[<d0f666be>] Not tainted VLI EFLAGS: 00013246 (2.6.17-RTAI #1) EIP is at rt_udp_recvmsg+0xd6/0x1b8 [rtipv4] eax: 00000000 ebx: cf82e5f4 ecx: 00003246 edx: 00000000 esi: 00000000 edi: ca401ee8 ebp: c60c4a90 esp: ca401e84 ds: 007b es: 007b ss: 0068 Process udpsendReceive (pid: 4313, threadinfo=ca400000 task=c60c4a90) Stack: cf82e618 ffffffff ffffffff 00000000 cf82e618 00000064 cf82e604 cf82e5e0 00000040 ca401ee8 c60c4a90 d0f6d666 cf82e5e0 c60c4a90 ca401ee8 00000040 fffffff2 ca401ee8 b7e1d2e0 c60c4a90 d0f6e940 c60c4a90 00000000 ca401ee8 Call Trace: <d0f6d666> _rtdm_recvmsg+0x4e/0x70 [rtai_rtdm] <d0f6e940> sys_rtdm_recvmsg+0x5e/0x82 [rtai_rtdm] <d0f8083f> rtai_lxrt_invoke+0x151/0x10c6 [rtai_lxrt] <d0f83be3> rt_task_make_periodic+0x0/0xed [rtai_lxrt] <d0f6e8e2> sys_rtdm_recvmsg+0x0/0x82 [rtai_rtdm] <c01176b1> sched_setscheduler+0x22c/0x269 <c0142e8d> __ipipe_dispatch_event+0x32/0x10d <d0f58053> rtai_syscall_dispatcher+0x55/0xeb [rtai_hal] <d0f5707e> rtai_uvec_handler+0x1a/0x30 [rtai_hal] Code: 00 8b 7c 24 14 e9 a9 00 00 00 8d 73 10 89 74 24 18 9c 59 fa 8b 73 10 85 f6 74 0e 8b 56 04 8b 02 89 43 10 c7 02 00 00 00 00 51 9d <8b> 4e 24 0f b7 51 04 0f b6 c2 c1 e0 08 c1 ea 08 09 d0 8d 68 f8 EIP: [<d0f666be>] rt_udp_recvmsg+0xd6/0x1b8 [rtipv4] SS:ESP 0068:ca401e84 LXRT releases PID 4313 (ID: udpsendReceive). _________________________________________________________________ MSN cricket features 'Cricketer of the Month' http://content.msn.co.in/Sports/Cricket/Default.aspx ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ RTnet-users mailing list RTnet-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rtnet-users