Results 1 to 2 of 2

Thread: Success - using several UDP clients on the same computer, same socket/port

  1. #1
    Superkart Pilot Maskmagog's Avatar
    Join Date
    Sep 2017
    Posts
    567
    Platform
    XBOX1 X

    Success - using several UDP clients on the same computer, same socket/port

    So, up until now, I thought it was impossible to have two different programs on the same computer, both listening to the UDP from Project Cars. Thankfully, many of you have released your programs on multiple platforms. So I've been able to run Crew Chief on an Android, PCLapUpdater (StoopidChallenges) on Windows, RS Dash on Iphone (and my own projectcalc on Raspberry Pi).

    Today I stumbled on somebodys project, where it looked like it could be possible to allow multiple clients to use the same port, on the same computer/device. Since I don't really know what I'm doing, it took a lot of trial and error, and most of my Saturday night, but suddenly it worked: I'm running two different versions of my program, on the same computer, and both programs receive the udp feed.

    I don't know if there's any downsides or other problems with this. That's where you come in

    This is the code I use (C#):
    Code:
    UdpClient listener = new UdpClient();    //Create a UDPClient object
    {
        listener.ExclusiveAddressUse = false; // Allow multiple clients to connect to the same socket/port
    };
    listener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); // Connect even if socket/port is in use
    
    listener.Client.Bind(new IPEndPoint(IPAddress.Any, 5606));
    IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 5606);   //Start receiving data from any IP listening on port 5606 (port for PCARS2)
    PCars1_UDP uDP = new PCars1_UDP(listener, groupEP);       //Create an UDP object that will retrieve telemetry values from in game.
    Obviously your code may do all this in a different way. The important bits are ExclusiveAddressUse = false, and the ReuseAddress, true.

    If any of you wants to incorporate this into your programs, I'd be happy to test.
    It would be cool to be able to run several programs on the same device at the same time, all listening to the udp feed. Not everybody has both an android, iphone, laptop etc.
    Thrustmaster TX, Italia 458 wheel, T3PA-Pro, Firmware 54, Xbox One X, public OS, 24" 1080 monitor
    Don't miss Yorkie065's excellent videos: Ep26-LiveTrack pt1. Ep 27-LiveTrack pt2.
    Project CALC - unified leaderboards - Forum thread
    The following user likes this Post: cpcdem


  2. #2
    Superkart Pilot Maskmagog's Avatar
    Join Date
    Sep 2017
    Posts
    567
    Platform
    XBOX1 X
    Well it seems that many programs already use this. Probably because they are made by actual programmers that know what they are doing.

    Well, now my app also can share socket/port Maybe this is good info for anyone developing an app anyway.
    Thrustmaster TX, Italia 458 wheel, T3PA-Pro, Firmware 54, Xbox One X, public OS, 24" 1080 monitor
    Don't miss Yorkie065's excellent videos: Ep26-LiveTrack pt1. Ep 27-LiveTrack pt2.
    Project CALC - unified leaderboards - Forum thread

Similar Threads

  1. The Sim-Racing Podcast Ep.1 | Has Project Cars 2 been a success?
    By KrypticTMG in forum Screenshots & Videos
    Replies: 0
    Last Post: 13-07-2018, 18:34
  2. Port Forwarding PS4
    By Sgt_PussaySniffer in forum Technical Help & Support (PS4)
    Replies: 4
    Last Post: 04-12-2017, 03:02
  3. Port Forwarding
    By jaccovdzaag in forum Technical Help & Support (PC)
    Replies: 7
    Last Post: 27-09-2017, 20:17
  4. Replies: 98
    Last Post: 23-04-2017, 00:44
  5. Very bad console port.
    By TomekCB in forum PS4 - Technical Help & Support
    Replies: 37
    Last Post: 18-05-2015, 01:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •