Hello everybody,

I was making some experiments to try to connect to SUMO and retrieving its data 
with C#, but I have been experiencing some problems with one of the most basic 
commands, which is performing a simulation step.
Looking at the documentation, I see I should send 10 bytes, right? this is: 4 
bytes (integer) for the targetTime, which I want to be 0, so it only performs 
one timestep, 1 byte for the identifier (0x02), 1 byte for command length (6), 
and 4 bytes for the total length(10).
This, in an array of bytes, would be like: [0,0,0,10,6,2,0,0,0,0].
I made this simple code just to test it, but it doesn't work at all. I mean, 
the connection with the server is done, but no timestep is performed and no 
response is received from the server (rather than an ACK).

This is the code:

public static void step(NetworkStream bw, int j)
        {
            byte[] bytes = { 0, 0, 0, 10, 6, 2, 0, 0, 0, 0 };
            bw.Write(bytes, 0, bytes.Length);
            bw.Flush();
        }

    public static void Main(String[] argv)
    {

        Socket socket = new Socket(AddressFamily.InterNetwork, 
SocketType.Stream, ProtocolType.Tcp);
        socket.NoDelay = true;
        try
        {
            socket.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 60634));
        }
        catch (Exception localConnectException)
        {
            Console.WriteLine(localConnectException.StackTrace.ToString());
        }
        NetworkStream ns = new NetworkStream(socket);
        //BinaryWriter bw = new BinaryWriter(ns); (I tried with both, 
BinaryWriter and NetworkStream and the result was the same
        for (int i = 0; i < 100; i++)
        {
            step(ns,i);
        }
}



                                          
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to