Code: Select all
97 void wxIRC::SendRaw(wxString string)
98 {
99 if(socket->IsConnected())
100 {
101 if(string.Right(1) != wxT("\n"))
102 {
103 string.Append(wxT("\n"));
104 }
105 const char *buf = (const char*) string.c_str();
106 unsigned int len = strlen(buf);
107
108 socket->Write((const void*) buf, len);
109 }
110 }
That's very dangerous code IMHO. We're using C++, so why should be still be using c-style casts? I'm suspecting that your c_str call is returning a wchar_t*, and in your C-style cast it is casted to const char* without warning or error. When you send it to Wireshark they may not completely see that it is encoded in UCS-2 and just show your 1 byte of information.
Also PLEASE practice some debugging techniques. If you're writing such a program I believe you have been programing for a while. So, try using GDB to see the value of buf to see if it is done correctly and stuff like that.
Oh, one more problem. If you are using CVS HEAD, c_str no longer returns const char* or const wchar_t*, its now wxCStrData. You may need to cast it to const char* to get the value out. Here is the next danger of using C-style casts, if it is an integer you cast it to be an address without knowing. In your call to socket->Write wxCStrData may have contained an implicit conversion function which may not work for the cast to const void*.
Joel