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.
I'd appreciate any assistance.
Thanks,
Peter