Socket messaging between roboguide and PC via c++ code

  • Hi all,

    I am new to socket messaging and karel programming and I am trying to establish a connection between roboguide (being the server) and my pc (being the client) via a C++ program but it won't work.


    I followed the Karel documentation on socket messaging to setup the server tag, but it doesn't mention to add a port number or a server IP, should I? As for the system variable $HOSTS_CFG[3], I've only configure the $SERVER_PORT to a random value: 8000.


    I've done multiple tests with different server_port (in $HOSTS_CFG[3] menu) numbers and server_IP value (in Host_Comm menu) such as the loopback IP adress 127.0.0.1 or the controller IP adress but nothing seems to work. Am i missing something?

    Here is my Karel code:


    And here is my c++ code:

  • It looks good. I would recommend checking some of the basics.

    What output do you get on the USER screen? This can help you determine if the connection is made.


    1. MSG_CONNECT( 'S3: ' , status) Why is there a space after the colon?

    2. I don't think you need to set a port number or a server IP in the Host Comm settings. You are setting the port in your Karel code.

    3. Are you testing this in Roboguide? If yes, then you can use telnet on your PC as a simple test to verify your Socket Messaging settings are correct. Open telnet and run the command "open 127.0.0.1 8000" (assuming you use port 8000). Then monitor the USER screen on the robot to see if you get the "Connect Status =" message. If you are able to connect you can send some characters in telnet.

    4. In Host Comm, check the HTTP Authentication screen. Verify that Karel is set to "Unlock".

  • Hi jmd2777,

    On the USER screen i have:


    Connect Status = 0

    connecting..


    Then the program waits for a client to connect to the port.


    1. Must have been a typo, i removed it but it didn't change anything.

    3. It fails to connect to the port via telnet..

    4. It is set to unlock.


    I feel like the problem must come from the Host Comm settings or the variables $HOSTS_CFG since it seems like the port 8000 isn't available (i'm using the CurrPorts app which list every opened port on the PC).

Advertising from our partners