I am developing a program that receives TCP packets from an OP7200 SBC. I am receiving the packets just fine, but now I am trying to extract the individual elements from the string so I can work with them. Here is the code I have so far:
Here is an example of the data I need to work with:Code:#include "ServerSocket.h" #include "SocketException.h" #include <string> #include <iostream> #include <stdio.h> int main ( int argc, int argv[] ) { try { // Create the socket ServerSocket server ( 14035 ); while ( true ) { ServerSocket new_sock; server.accept ( new_sock ); try { while ( true ) { std::string data; new_sock >> data; new_sock << data; using namespace std; string trainid(data); cout << "Data received: " << trainid << endl; } } catch ( SocketException& ) {} } } catch ( SocketException& e ) { std::cout << "Exception was caught:" << e.description() << "\nExiting.\n"; } return 0; }
Unit Name: Name of the location the next two numbers pertain to.Code:Unit Name,1,2
1: Unit #
2: Number of Cycles on Unit
I know the solution is probably simple, but I am fairly new to C and C++. I'm having a hard time understanding some of the stuff I've gound on Google. The program I have so far is nothing more than code I used from an excellent socket programming tutorial. I've done PHP and VB programming in the past. This is my first time writing a program for a Linux box.
Thanks!
Chris