Quote:
Originally Posted by JohnM
I decided to drop ntcore and just try to use a TCP socket. I want the robot to be the server and the ds to be the client. I'm using the winsock library on the Windows ds and my question was if this and this could be used for setting up a TCP socket stream with the DS. Or will I have to use regular linux socket calls. Is there any C++ examples using the WPILIB version? Also a concern of my is when I'm using the receive function will it stall the code until the server receives something?
|
The issue you're running into with mingw32 is likely lack of support in mingw for std::mutex. See
https://github.com/meganz/mingw-std-threads for a possible solution (however, it will require editing a number of the ntcore source files). Alternatively if you can use mingw64, which may have the necessary support built in.
If you're rolling your own, the two classes you're referencing are actually part of ntcore, and while they're present in the library and docs, headers aren't installed for them at present (you can however copy the necessary headers from the ntcore source), and as they were actually intended for ntcore-internal usage, there's no examples. These two classes are pretty basic wrappers around Linux socket calls. Yes, accept() and receive() are blocking calls (although you can specify a timeout for receive to make it semi-non-blocking), so you should put them in a separate thread.
__________________
Author of
ntcore - WPILib NetworkTables for 2016+
Creator of
RobotPy - Python for FRC
2010 FRC World Champions (
294, 67, 177)
2007 FTC World Champions (30, 74,
23)
2001 FRC National Champions (71,
294, 125, 365, 279)