Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Writing output to and receiving output on a socket

Hi Peter,

in my opinion the meta code for your server should be:

main
    do the init stuff
    register DataAvailableCall
    start EventLoop

DataAvailableCall
    read data from socket
    process data

I have no idea, how register DataAvailableCall and EventLoop are implemented in the library you use.

Regards Harald

Am 30.03.19 um 22:49 schrieb PETER MARCHIONE:
Hello,

Sorry for asking about the same topic twice, but I didn't get a response when I asked a follow up question. I'm trying to open a server socket that listens for only one client and outputs to the console or a file (whichever I chose).

According to Michael, who responded last time, this code should do:
import socket
    port = 1338
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("localhost", port))
    s.listen(1)
    conn, addr = s.accept()
    f = conn.makefile('rb') 

There is a python script that has this code, but I'm trying to reimplement it in C++. Specifically, I am looking into using socket.h and socket.cpp, which already comes with the SUMO repository: https://github.com/eclipse/sumo/tree/master/src/foreign/tcpip

The only code I've written is basically me creating a Socket object and testing some of the functions.

I expect to be able to use socket.h/socket.cpp to listen in on what SUMO is outputting instead of having it write to a file.

Here's my code. The /=== line separates the two programs I have. I have two programs, one that acts as the server (well, it's supposed to) and the one that runs SUMO, which from my understanding is the client.

https://hastebin.com/ufizadofaf.cpp 

Currently, all I get is this error.

image.png

I'd appreciate any assistance.

Thanks,

Peter

 


 


_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user



Back to the top