PDA

View Full Version : Grabbing InSim UDP packets while using a TCP connection


MaKaKaZo
5th August 2008, 08:54
Hi. I was about to do my first test on LFS coordinates in IS_MCI packets and I've come to the followign point.

I have been using InSim TCP connection all the time for my previous tests, but I saw in the documentation that there's the possibility to tell InSim to send only the IS_MCI/IS_NLP packets via UDP, while the rest of hte packets would use TCP.

If I want to receive MCI packets every one second this looks the best way to not get too much TCP traffic overhead.

Now this may be a stupid question, but as I'm not much into sockets... would I need t setup two sockets for this? One for the TCP connection and another for the UDP? I guess that's the way, but I just want someone to tell me to make sure.

I'll be doing tests for a couple of hours anyway ;)

T-RonX
5th August 2008, 10:07
Yes you have to setup both sockets. :)

MaKaKaZo
5th August 2008, 10:20
This is awful :( Now I'll need to create an independent thread to handle all the UDP packets, because tge select() call would make it inappropiate within the main loop. Now I'll need two "main loops" working on different threads, one or TCP packets and one for UDP packets :shrug:

Dygear
7th August 2008, 23:15
Main Loop -> UDP Loop & TCP Loop.

The main loop could be it's own process while the child threads of the UDP (Handles only MCI & NPL Packets.) and TCP (Handles all but MCI & NPL Packets.) could be child threads of the main process.

MaKaKaZo
8th August 2008, 08:36
Main Loop -> UDP Loop & TCP Loop.

The main loop could be it's own process while the child threads of the UDP (Handles only MCI & NPL Packets.) and TCP (Handles all but MCI & NPL Packets.) could be child threads of the main process.

Well, right now I have the main function with the TCP loop, and right before this TCP loop I create and launch the child thread with the UDP loop.

What I'm guessing now is whether in ending the threads in a good way or not. The child (UDP) thread is canceled by the main function right after the TCP loop ends. Maybe I should add the same control variable to both loops and join them... Well, just thinking aloud :)