wxsocket packet

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
1van
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Nov 17, 2012 4:23 am

wxsocket packet

Post by 1van » Tue Feb 05, 2013 7:47 pm

Hi.
There is an client-server application. For example, a client sends server a packet like this:
<byte of beginning of the string> + <command> + <the name of the user who sends> + <the name of the user who receives> + <message> + <byte of ending of the string>
How can I split this packet onto <command>, <the name of the user who sends>, <the name of the user who receives>, <message> separately? Can I use wxstringtokenizer or are there the other methods?
Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14972
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxsocket packet

Post by doublemax » Tue Feb 05, 2013 10:06 pm

The the whole string is under your control, you can do what you like. E.g. if you know for sure that the character '$' never appears anywhere else in the string, you could use it as a separator. Or you could url-encode the string, or, or, or. There are hundreds of options, wxStringTokenizer is one of them.
Use the source, Luke!

Post Reply