View Single Post
  #14  
Old 04-28-2005, 10:26 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I did some tests here and got it working. Here is the C++ code I used to generate the packet:
Code:
std::string packString(const char *message)
{
	std::string pack = message;
	int stringLen = ceil( (pack.size() + 1) / 4.0 ) * 4;
	for(int i = pack.size(); i < stringLen; i++)

		pack += '\0';
	return pack;
}

std::string createPacket(const char *message)
{
	return packString("master") + packString(",s") + packString(message);
}
The createPacket function uses the packString function to generate 3 string packets. The first string packet is the address of the computer you are sending from. You can set this to whatever you want. The second string packet is the type of the data. If you will only be sending one string then you don't need to change this. The last string packet is the message you want to send. The packString function simply pads the string with some NULL characters. After this, simply send the string returned by createPacket over the socket. Let me know if you can't get this working.
Reply With Quote